-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use lazy evaluated Type Annotations from PEP 563 #650
Conversation
Also credits to @tatiana she brought it up first in #384 (comment) |
0163466
to
9f60b12
Compare
There are some caveats though as listed in https://mypy.readthedocs.io/en/stable/runtime_troubles.html#future-annotations-import-pep-563. @uranusjr Is it safe to use this or should we wait till we drop support for Python 3.7 and 3.8? |
Codecov Report
@@ Coverage Diff @@
## main #650 +/- ##
==========================================
+ Coverage 92.47% 93.00% +0.52%
==========================================
Files 42 42
Lines 1701 1715 +14
Branches 216 212 -4
==========================================
+ Hits 1573 1595 +22
+ Misses 102 98 -4
+ Partials 26 22 -4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There are a couple of suggestions from They are unrelated to this PR but should we fix them as part of this PR? |
Details: https://peps.python.org/pep-0563/ and https://discuss.python.org/t/type-annotations-pep-649-and-pep-563/11363/20 tl_dr: This PEP lazy evaluates Annotations so they are not evaluated at parse time and allows forward references as well. This also includes https://peps.python.org/pep-0604/ which allows writing typing.Union[int, str]` as `int | str` and includes https://peps.python.org/pep-0585/ which allows us to write `def f(x: List[str]) -> None` to `def f(x: list[str]) -> None`
52d9389
to
674f2fa
Compare
Details: https://peps.python.org/pep-0563/ and https://discuss.python.org/t/type-annotations-pep-649-and-pep-563/11363/20 tl_dr: This PEP lazy evaluates Annotations so they are not evaluated at parse time and allows forward references as well. This also includes https://peps.python.org/pep-0604/ which allows writing §typing.Union[int, str]` as `int | str` and includes https://peps.python.org/pep-0585/ which allows us to write `def f(x: List[str]) -> None` to `def f(x: list[str]) -> None`
Details: https://peps.python.org/pep-0563/ and https://discuss.python.org/t/type-annotations-pep-649-and-pep-563/11363/20
tl_dr: This PEP lazy evaluates Annotations so they are not evaluated at parse time and allows forward references as well.
This also includes https://peps.python.org/pep-0604/ which allows writing
typing.Union[int, str]
asint | str
and includes https://peps.python.org/pep-0585/ which allows us to writedef f(x: List[str]) -> None
todef f(x: list[str]) -> None