-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Adding # type: ignore to EnumClass[string_value] doesn't set the type to Any #2416
Comments
This was introduced by 57ff82b (PR #2378, Implement generic type aliases). @ilevkivskyi Can you look into this? It would break our internal build (if we were to update mypy). |
@gvanrossum The problem itself appear because ignored line is interpreted by mypy as This is a common behaviour. For example: def g() -> Dict[int]: # type: ignore
...
reveal_type(g()) # Revealed type is Dict[Any, Any] My recent PR just brought this behaviour also to aliases (before aliases always returned I think the right way to fix this is to mark such "recovered" instances as invalid, so that they could be turned into The mentioned PR fixes the problem, but I am thinking maybe we should reconsider recovery after errors (PEP 484 seems to be silent about this): should errors always lead to |
Fixes #2416. This is a minimalistic fix (basically just restoring status quo for invalid aliases).
Example:
We have to use
# type: ignore
on the linee = E[s]
because of #741. But somehow the type ofe
, when ignoring the error, is notAny
but something else. So on the last line we getThe weird thing is that if e had type E, d[e] would be valid, so the error is also somehow lying...
UPDATE: When trying to repro this, don't try E['V'] -- mypy sees the literal and gives some other error, probably also because of #741.
The text was updated successfully, but these errors were encountered: