
Thanks so much for the responses to the initial PEP draft. - Shorthand Union + Optional Convention I wanted to address this question:
My question [...] is which variant should we recommend, and why?
Reading through the examples provided, Flow provides syntax most similar to the optional syntax proposed in the PEP. ``` // Flow examples. function foo(x: ?number | string) {} function bar(x: ?(number | string)) {} function baz(x: number | ?string) {} ```
It looks way less readable compared to TS.
In my opinion, this looks less readable because of the placement of the ? operator. For the Python syntax, I would suggest that the convention be to always add the ? at the end of the annotation. ``` # examples def foo(x: int | str?): ... def bar(x: list[int | str?]): ... ``` Of the available options, I find this to be the easiest to digest at a glance, and the most concise. - Dunder Method
Finally -- wouldn't we need to have a new dunder method/protocol so the operator can be overloaded for other functionality?
Yes, thanks so much for this, we would need a new dunder method. I will update the PEP draft and the linked reference implementation. - Sponsorship
So if you can't find someone else to sponsor it, I will, even though when it comes down to accepting it I would probably recommend that the SC reject it. Even that would be useful, since then we can point to the rejected PEP when the idea is brought up again. :-)
I appreciate the honesty. Thanks for offering! :) As next steps, I'll update the PEP draft with these suggestions. Thanks again, Maggie