For me the feeling is that the ? denotes better optional, ~int to me feels more like not int... than int or None :-)On Fri, Sep 20, 2019 at 10:19 AM Philippe Prados <philippe.prados@gmail.com> wrote:_______________________________________________Hello everybody,Scala 3 propose a new syntax for Union type. See here. I propose to add a similar syntax in Python.
Now, it's possible to write:
in place of
The discussion on python-new@python.org here have emerged the idea of extending also issubclass() and isinstance().
I think these syntaxes are more clear, and can help with the adoption of typing.
I test and implement these ideas in a two fork : One for CPython and one for MyPy. See the branches add_OR_to_types (for Union syntax), add_INVERT_to_types (for Union and Optional syntax) or updage_isinstance (for new isinstance() and issubclass()).
How I implement that ? I add the operators __or__ and __revert__ to PyType_Type. The C code is similar of :
with some check before return Union.
Actually, the accepted BNF syntax for typing is :
I propose to extend the BNF syntax to :
Your remarks are welcome.
Philippe Prados
Typing-sig mailing list -- typing-sig@python.org
To unsubscribe send an email to typing-sig-leave@python.org
https://mail.python.org/mailman3/lists/typing-sig.python.org/