_______________________________________________Hello everybody,
Scala 3 propose the 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
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) or add_INVERT_to_types (for Union and Optional syntax).
How I implement that ? I add the operators __or__ and __revert__ to PyType_Type. The C code is similar of :
Actually, the accepted syntax for typing is :
I propose to extend the syntax to :
What do you think about that ?
The draft of a PEP is here.
Regards
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/FCTXGDT2NNKRJQ6CDEPWUXHVG2AAQZZY/
Code of Conduct: http://python.org/psf/codeofconduct/