-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
self type on property creates a spurious error #3223
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
Comments
Is it the same if you rename |
Yes, doesn't make a difference. |
I should look into it. Note that adding a bound, i.e. |
Thanks! FYI, the code where I found this had a |
elazarg
added a commit
to elazarg/mypy
that referenced
this issue
Sep 26, 2017
1. Reverse subtyping check for self argument 2. For classmethod, fallback on the argument instead of on the parameter 3. Mimic dispatch better: meet original_type with static class 4. Better error message
JukkaL
pushed a commit
that referenced
this issue
Oct 12, 2017
…take 2) (#4016) Fix #3223. Minimal examples: ``` from typing import Callable class X: f: Callable[[object], None] X().f # E: Invalid method type ``` ``` class X: @Property def g(self: object): pass X().g # E: Invalid method type ``` The problem is that for non-methods the check performed on access to self is whether object <: X instead of the other way around. 1. Reverse subtyping check. This change alone fixes the issue described above. 2. For classmethod, fall back on the argument instead of on the parameter. 3. Mimic dispatch better: meet original_type with static class. This handles the case were instead of X() above there was something of type Union[X, Y]. 4. Better error message. Take 2 of #3227, but without the reverse-operator part.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Running mypy master on this file:
gives
The revealed type is correct but the "Invalid method type" doesn't make sense.
The text was updated successfully, but these errors were encountered: