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
When overriding __new__() in a BaseException subclass, a call of form super().__new__(cls, arg0, [arg1, [arg2, ...]]]) causes type checkers to complain about unused positional argument(s), even though the positional args are both accepted and used by BaseException.__new__() — they become <BaseException>.args.
Root cause: type checkers believe super().__new__(...) in this context is a call to object.__new__(), rather than BaseException.__new__().
Proposed fix: typeshed should include a definition for BaseException.__new__() analogous to and compatible with to its existing signature for BaseException.__init__():
Summary
When overriding
__new__()
in aBaseException
subclass, a call of formsuper().__new__(cls, arg0, [arg1, [arg2, ...]]])
causes type checkers to complain about unused positional argument(s), even though the positional args are both accepted and used byBaseException.__new__()
— they become<BaseException>.args
.Root cause: type checkers believe
super().__new__(...)
in this context is a call toobject.__new__()
, rather thanBaseException.__new__()
.Proposed fix: typeshed should include a definition for
BaseException.__new__()
analogous to and compatible with to its existing signature forBaseException.__init__()
:Concrete example
Analyzing the following code....
...with mypy causes this report:
...while pyright (without
strict
) says:The text was updated successfully, but these errors were encountered: