Skip to content
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

Annotations in typing.Annotated are not checked #10872

Open
NiklasRosenstein opened this issue Jul 25, 2021 · 1 comment
Open

Annotations in typing.Annotated are not checked #10872

NiklasRosenstein opened this issue Jul 25, 2021 · 1 comment
Labels
bug mypy got something wrong

Comments

@NiklasRosenstein
Copy link

Bug Report

To Reproduce

import typing_extensions as te
x: te.Annotated[int, Foobar] = 42

Expected Behavior

Mypy complains about Foobar not being defined. In other cases, e.g. when a function is called in an Annotated argument, it checks if the arguments passed to the function are valid (or number of arguments match, etc. etc.).

Actual Behavior

Mypy does not complain about Foobar not being defined.

Your Environment

  • Mypy version used: 0.910
  • Mypy command-line flags: n/a
  • Mypy configuration options from mypy.ini (and other config files): n/a
  • Python version used: 3.8.2
  • Operating system and version: OSX
@NiklasRosenstein NiklasRosenstein added the bug mypy got something wrong label Jul 25, 2021
@hauntsaninja
Copy link
Collaborator

I think this is a result of #9625
People even want this non-checking to be extended to all usages of Annotated, e.g., see #10777

Fwiw, my reading of PEP 593 is that mypy should complain about your example, but not if from __future__ import annotations, since then it won't fail at runtime and falls more under the category of "Unknown annotations" which PEP 593 says type checkers should ignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants