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
{{ message }}
Repository navigation
no error when calling abstract super method with body #5145
abstractmethods with an implementation should be an error in most cases (see #5143), but either way an error should still be reported when calling one from a base class, especially if its implementation just raises NotImplementedError.
If I understand correctly, the problem is that we report the expected error when the abstract method has body ... but not when it has body raise NotImplementedError?
yeah. while it is arguably valid for an abstract method to have an implementation (see #5143 and discussion in astral-sh/ty#4693), i think an "implementation" that just raises NotImplementedError should probably just be special-cased to mean the same thing as no implementation.
Both body-kind matches now include BodyKind::RaiseNotImplementedError, so an abstract method whose body is only a NotImplementedError raise is treated as unimplemented. super() then reports that the inherited method has no implementation, and a direct call reports that the abstract method cannot be called.
Activity
rchen152 commentedon Oct 13, 2026
If I understand correctly, the problem is that we report the expected error when the abstract method has body
...but not when it has bodyraise NotImplementedError?DetachHead commentedon Oct 13, 2026
yeah. while it is arguably valid for an abstract method to have an implementation (see #5143 and discussion in astral-sh/ty#4693), i think an "implementation" that just raises
NotImplementedErrorshould probably just be special-cased to mean the same thing as no implementation.mvanhorn commentedon Oct 13, 2026
Both body-kind matches now include BodyKind::RaiseNotImplementedError, so an abstract method whose body is only a NotImplementedError raise is treated as unimplemented. super() then reports that the inherited method has no implementation, and a direct call reports that the abstract method cannot be called.
#5216
Error on super() calls to abstract methods that only raise NotImpleme…