You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It also seems like the current behaviour is that mypy considers all type annotations to be using postponed evaluation, even when missing the future statement. For example, mypy reports no issues with the following code:
classX:
deffunc(self) ->X:
pass
As expected, it will not run without from __future__ import annotations.
Based on the title of the linked documentation page ("Annotation issues at runtime") and the opening sentence, it suggests that this might be intended behaviour? If so, can this please be added to the documentation? (If it's not intended behaviour, I can file a bug, but didn't want to open extra issues unnecessarily.)
The text was updated successfully, but these errors were encountered:
Yes, it's a missing feature in mypy that it won't warn you about that code (e.g. maybe see #948). mypy definitely should warn the user about that code (and mypy does warn about some other issues on similar lines). Probably a somewhat tricky feature to add though.
Documentation
As per the mailing list, the postponed evaluation of annotations has been deferred to 3.11.
However, the docs still refer to it becoming default in 3.10: https://mypy.readthedocs.io/en/stable/runtime_troubles.html
It also seems like the current behaviour is that
mypy
considers all type annotations to be using postponed evaluation, even when missing the future statement. For example,mypy
reports no issues with the following code:As expected, it will not run without
from __future__ import annotations
.Based on the title of the linked documentation page ("Annotation issues at runtime") and the opening sentence, it suggests that this might be intended behaviour? If so, can this please be added to the documentation? (If it's not intended behaviour, I can file a bug, but didn't want to open extra issues unnecessarily.)
The text was updated successfully, but these errors were encountered: