-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Overload ambiguity is ignored in self
-annotated methods
#11347
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Simplified reproductionWithout
|
On the second thought: why s3: Some[Any]
reveal_type(s3.method()) # N: Revealed type is "builtins.bool"
# Should be: Revealed type is "Union[bool, float]" |
I imagine this would be a great addition if we had a dedicated unsafe-union-type (e.g. python/typing#566), |
Yeap, @BvB93! I've decided that this is out of scope 👍 |
BTW: this issue is why the solution #10207 (comment) does not work in Mypy. |
Currently not working in Mypy because of python/mypy#11347
Bug Report
Per the title: mypy does not check for overload ambiguity in
self
-annotated methods.Mypy will instead, effectively, ignore
self
and then return the first matching overload,thus circumventing the usual
Any
that is returned when overload ambiguity is involved.This has lead to a number of false positives in numpy/numpy#20099 and (in part) numpy/numpy#20072.
The conditions for triggering this bug are as following:
self
must be annotated with a parametrized generic.To Reproduce
Your Environment
mypy.ini
(and other config files): n.a.The text was updated successfully, but these errors were encountered: