If @deprecated is applied to a class which defines __new__ but not __init__, it applies this check from object.__new__(), causing a TypeError from code that otherwise works fine:
from typing_extensions import deprecated
@deprecated("something")
class OnlyHasNew:
def __new__(cls, a: int, b: float) -> 'OnlyHasNew':
obj = object.__new__(cls)
obj.a = a
obj.b = b
return obj
OnlyHasNew(1, 2) # TypeError: OnlyHasNew() takes no arguments
It seems like that check should be moved into the else: branch there. I originally found this when trying to deprecate a NamedTuple class, which is potentially a more likely way to run into this issue.
If
@deprecatedis applied to a class which defines__new__but not__init__, it applies this check fromobject.__new__(), causing aTypeErrorfrom code that otherwise works fine:It seems like that check should be moved into the
else:branch there. I originally found this when trying to deprecate aNamedTupleclass, which is potentially a more likely way to run into this issue.