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
class A:
def __init__(self, x: int) -> None:
pass
class B(A):
def __new__(cls) -> 'B':
return object.__new__(cls)
B()
even though it crashes at runtime.
Per #5642 (review):
The rule CPython uses is this (for a class C with superclass B, where B is not object):
If both C.__new__ and C.__init__ refer to their versions in object, the signature is def () -> C.
If exactly one of C.__new__ and C.__object__ refers to its object version, the other determines the signature.
If both override their corresponding object versions, they must match -- even if they don't come from the same class (say, if one comes from C and the other from B).
Activity
msullivan commentedon Sep 19, 2018
Actually closing as a dupe of #1019