Multiple people have suggested a shorter syntax to replace Optional[...]
. The current syntax will become more inconvenient if we don't infer optional types from None
default values (see #275).
Here are various options that I remember seeing proposed:
x?
or ?x
This would require new Python syntax.
Hack uses ?x
. TypeScript uses x?
for names, not types, if I've understood things correctly.
x | None
This would require support for |
for all type objects, which would not be backward compatible.
The |
operator is used by TypeScript.
{x}
Probably not an option as this is too cryptic. Suggested in #151 .
from typing import Optional as O
or from typing import Optional as Opt
This is not actually a new syntax and works currently. These are arguably inelegant.
feluxe, Naddiseo, NN---, perkfly, c6401 and 19 more
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4