Skip to content

Docs: Postponed evaluation of annotations deferred to 3.11 #10648

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

Closed
ShadowLNC opened this issue Jun 15, 2021 · 1 comment · Fixed by #10655
Closed

Docs: Postponed evaluation of annotations deferred to 3.11 #10648

ShadowLNC opened this issue Jun 15, 2021 · 1 comment · Fixed by #10655

Comments

@ShadowLNC
Copy link

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:

class X:
    def func(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.)

@hauntsaninja
Copy link
Collaborator

Thanks, yeah, that should be updated. PR welcome!

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.

hellocoldworld added a commit to hellocoldworld/mypy that referenced this issue Jun 16, 2021
Postponed evaluation of annotations was deferred to 3.11 - update the docs.
JukkaL pushed a commit that referenced this issue Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants