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
If I create a protocol with a method that uses a type variable to annotate both self and the first argument of the method, mypy will accept as subtype, classes with methods accepting as first argument a parameter of the same class type. This unrestricted behavior can be used to get around the type system.
This is not something specific to protocols. Exactly the same problem exists for nominal classes that use self-types. So this is almost a duplicate of #2353. I think it not exactly a duplicate because the solution for protocols may be different (but likely we will just go with the option 4 proposed by @JukkaL).
If I create a protocol with a method that uses a type variable to annotate both
self
and the first argument of the method, mypy will accept as subtype, classes with methods accepting as first argument a parameter of the same class type. This unrestricted behavior can be used to get around the type system.The text was updated successfully, but these errors were encountered: