No, it's not possible, because
Regards
Philippe PradosLe jeu. 29 août 2019 à 14:55, Inada Naoki <songofacandy@gmail.com> a écrit :I don't want to add runtime behaviors for static type hinting.There is PEP 563 instead.Tools like mypy can implement them without touching runtime behavior.On Thu, Aug 29, 2019 at 9:48 PM Philippe Prados <philippe.prados@gmail.com> wrote:_______________________________________________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/
--Inada Naoki <songofacandy@gmail.com>