You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on several mypy plugins I had often step on the fact you cannot subclass any of the mypy classes, because they are compiled with mypyc. It caused runtime TypeError in the plugin's code.
But, when I was trying to run mypy on the plugin's code - it was fine, no error was shown. Because type are not @final and mypy is not able to understand that this is a problem.
So, I propose to add explicit @final annotations to almost all types, exception:
Types with allow_interpreted_subclasses
Types that are subclassed inside mypy itself: Node, Expression, TypeQuery, etc
One more strong point to making this change is that many classes are not "designed" to be subclassed.
So, this should not be a problem.
While working on several
mypy
plugins I had often step on the fact you cannot subclass any of themypy
classes, because they are compiled withmypyc
. It caused runtimeTypeError
in the plugin's code.But, when I was trying to run
mypy
on the plugin's code - it was fine, no error was shown. Because type are not@final
andmypy
is not able to understand that this is a problem.So, I propose to add explicit
@final
annotations to almost all types, exception:allow_interpreted_subclasses
mypy
itself:Node
,Expression
,TypeQuery
, etcOne more strong point to making this change is that many classes are not "designed" to be subclassed.
So, this should not be a problem.
Related #10125
Related #9602
The text was updated successfully, but these errors were encountered: