Fix overloading with a typevar missing#15320
Conversation
This comment has been minimized.
This comment has been minimized.
|
mypy primer output: tanjun, this is why I made the change 👍 koda-validate, I literally cannot parse what they're doing with my brain. But it feels like that's this PR messing up, 👎 expression seems like yeah that error is valid, but I don't think the changes made by this PR should reveal that. Or actually I don't know if mypy acknowledges that that error is valid at all, that for spark I'm not sure if mypy views steam.py I genuinely dunno, would need to think more about it discord.py is correct 👍 Anyways, all in all, I think I might need to reconsider some of the changes I made with this PR (I removed something that seemed unnecessary before reviving it) or at least take a good look at some of the failures. |
sobolevn
left a comment
There was a problem hiding this comment.
Please, don't forget to add tests :)
|
|
||
| class A: ... | ||
|
|
||
| T = typing.TypeVar("T", bound=A) |
There was a problem hiding this comment.
I should investigate why current mypy is a-ok without the bound=A here, but errors when it is. That's strange and probably a sign of incorrect special casing: something I hate!
This comment has been minimized.
This comment has been minimized.
|
Diff from mypy_primer, showing the effect of this PR on open source code: Tanjun (https://github.com/FasterSpeeding/Tanjun)
+ tanjun/annotations.py:1225: error: Overloaded function implementation does not accept all possible arguments of signature 1 [misc]
+ tanjun/annotations.py:1225: error: Overloaded function implementation cannot produce return type of signature 1 [misc]
vision (https://github.com/pytorch/vision): typechecking got 1.36x slower (39.2s -> 53.2s)
(Performance measurements are based on a single noisy sample)
more-itertools (https://github.com/more-itertools/more-itertools)
+ more_itertools/more.pyi:411: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [misc]
spark (https://github.com/apache/spark)
+ python/pyspark/sql/functions.py:4640: error: Overloaded function implementation does not accept all possible arguments of signature 2 [misc]
+ python/pyspark/sql/functions.py:9186: error: Overloaded function implementation does not accept all possible arguments of signature 2 [misc]
+ python/pyspark/sql/functions.py:9266: error: Overloaded function implementation does not accept all possible arguments of signature 2 [misc]
+ python/pyspark/sql/functions.py:11102: error: Overloaded function implementation does not accept all possible arguments of signature 2 [misc]
steam.py (https://github.com/Gobot1234/steam.py)
- steam/ext/commands/commands.py:732: error: Overloaded function implementation does not accept all possible arguments of signature 3 [misc]
+ steam/ext/commands/commands.py:732: error: Overloaded function implementation cannot satisfy signature 3 due to inconsistencies in how they use type variables [misc]
+ steam/ext/commands/commands.py:801: error: Overloaded function implementation cannot satisfy signature 3 due to inconsistencies in how they use type variables [misc]
+ steam/ext/commands/commands.py:907: error: Overloaded function implementation cannot satisfy signature 3 due to inconsistencies in how they use type variables [misc]
+ steam/ext/commands/commands.py:974: error: Overloaded function implementation cannot satisfy signature 3 due to inconsistencies in how they use type variables [misc]
+ steam/ext/commands/commands.py:1080: error: Value of type variable "MC" of "__call__" of "CommandDeco" cannot be "MCD" [type-var]
+ steam/ext/commands/commands.py:1105: error: Value of type variable "MC" of "__call__" of "CommandDeco" cannot be "MCD" [type-var]
discord.py (https://github.com/Rapptz/discord.py)
+ discord/ext/commands/core.py:1729: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [misc]
+ discord/ext/commands/core.py:1799: error: Overloaded function signatures 1 and 2 overlap with incompatible return types [misc]
|
Yeah, that's how to mark arguments as positional only in older Python versions. |
Resubmitting #11617 cause that was pre-Blackened mypy. Also, that PR probably won't get any eyes anymore.
This fixes #9023. I still need to add a test about this, unfortunately.