-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Error message for typing_extensions.Self is confusing #14089
Comments
There is actually an open PR to add full support for |
Great! Let's then link these two together, just in case the PR gets stuck. @ilevkivskyi could you add "Fixes #14089" into the description of #14041, please? |
Ref #12840 Fixes #11871 Fixes #14089 This is an alternative implementation to two existing PRs: #11666, #13133. This PR treats `typing.Self` as pure syntactic sugar, and transforms it into a type variable early during semantic analyzis. This way we can re-use all the existing machinery and handled edge cases for self-types. The only new thing is self-type for _attributes_ (as proposed in the PEP). This required handling in several places, since attribute access is duplicated in several places (see #7724), plus special forms (like NamedTuples and TypedDicts) and dataclasses plugin require additional care, since they use attribute annotations in special ways. I don't copy all the existing tests for "old style" self-types, but only some common use cases, possible error conditions, and relevant new edge cases, such as e.g. special forms mentioned above, and implicit type variable binding for callable types.
Bug Report
It looks like mypy doesn't support
typing_extensions.Self
. I know that Rome wasn't built in a day and the work in #11871 is on the way. However, while it's still in progress, I think it would be great to have a user-friendly error message that better explains the nature of the error.To Reproduce
Expected Behavior
I'd expect a user-friendly error message explaining the nature of the issue, something like this:
Actual Behavior
Your Environment
mypy tmp.py
mypy.ini
(and other config files):-
3.10.6
#14089 (comment)
The text was updated successfully, but these errors were encountered: