#8483 by @sobolevn deleted decimal.Context.__delattr__ from the stub, on the grounds that it had the exact same signature as builtins.object.__delattr__.
I think the rationale for this deletion was incorrect, as overriding __delattr__ on a subclass can cause a type checker to give that class special semantics, even if the signature of __delattr__ is identical to object.__delattr__. For example:
classFoo: ...
classBar:
def__delattr__(self, __name: str) ->None: ...
f=Foo()
b=Bar()
delf.spam# mypy and pyright both emit an error here# mypy emits an error here (it does not special-case __delattr__)# pyright does *not* emit an error here (it special-cases __delattr__ to allow arbitrary deletions if __delattr__ is overridden)delb.spam
In the specific case of Context.__delattr__, however, I'm not sure whether it should be present in the stub or not. This is the behaviour you get at runtime:
>>>importdecimal>>>c=decimal.Context()
>>>c.prec=54>>>delc.precTraceback (mostrecentcalllast):
File"<stdin>", line1, in<module>AttributeError: contextattributescannotbedeleted
Maybe we could represent this by adding Context.__delattr__ back to the stub and giving it the signature def __delattr__(self, __name: str) -> NoReturn?
#8483 by @sobolevn deleted
decimal.Context.__delattr__from the stub, on the grounds that it had the exact same signature asbuiltins.object.__delattr__.I think the rationale for this deletion was incorrect, as overriding
__delattr__on a subclass can cause a type checker to give that class special semantics, even if the signature of__delattr__is identical toobject.__delattr__. For example:In the specific case of
Context.__delattr__, however, I'm not sure whether it should be present in the stub or not. This is the behaviour you get at runtime:Maybe we could represent this by adding
Context.__delattr__back to the stub and giving it the signaturedef __delattr__(self, __name: str) -> NoReturn?