-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
stdlib/ssl.pyi currently contains a definition for ssl.SSLContext.__init__() with the protocol argument. But the actual type in stdlib does not define __init__() at all, only __new__().
On attempting to subclass SSLContext while overriding only __new__() method (with another set of arguments) type checker will incorrectly show an error (incompatibility between constructors). On the other hand, when overriding both __new__() and __init__() and calling super().__init__(protocol), type checker will not complain, though the code will in fact produce a TypeError: object.__init__() takes exactly one argument (the instance to initialize) at runtime.
Would it be correct to remove __init__ definition from SSLContext class, leaving only __new__? I have edited the local typeshed copy that pylance uses on my computer and it seems to work (removes the error in the first case and shows an error in the second).