super() is analyzed differently from super(C, self) in generic subclass context #13039
Labels
bug
mypy got something wrong
topic-inheritance
Inheritance and incompatible overrides
topic-type-variables
Uh oh!
There was an error while loading. Please reload this page.
Bug Report
Consider a minimal reproducing example, based on one from #7362
(https://mypy-play.net/?mypy=0.961&python=3.10&gist=ab00ab8ee474443b979cb00ea4284946)
This is clearly unexpected, as this should work normally. However, if instead of writing
super()
, we writesuper(C, self)
, which is exactly equivalent syntactically in Python 3, we get(https://mypy-play.net/?mypy=0.961&python=3.10&gist=44206838005bf4acfa264a42eecb0eb5)
As expected.
Possible fix
Here, Mypy is analyzing
super()
, differently fromsuper(C, self)
, which is syntactically incorrect. Ifsuper()
would instead be (correctly) parsed assuper(C, self)
in this case, the problem disappears. Note that this also fixes #7362 and #10130.I don't know enough about Mypy internals to understand why Mypy does not take
super()
to be equal tosuper(C, self)
here, but perhaps this could be an easy fix?2024 edit
This reproduces on
1.8.0
as well.The text was updated successfully, but these errors were encountered: