Repository navigation
fix: skip missing-super-call for abstract or protocol method overrides - #5474
Open
Aayushyaash wants to merge 2 commits into
Open
Aayushyaash wants to merge 2 commits into
Aayushyaash wants to merge 2 commits into
Conversation
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D128855918. (Because this pull request was imported automatically, there will not be any future comments.) |
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In an executable
.pyfile, when an abstract class or sub-protocol overrides a constructor-like method (__init__,__new__, or__init_subclass__) to declare or refine a signature with a placeholder body (...,pass, orraise NotImplementedError), Pyrefly reported a false-positivemissing-super-callerror.While #5180 skipped
.pyistubs andif TYPE_CHECKING:blocks, overriding methods in runtime.pyfiles were still required to callsuper(), even when the overriding method itself was an abstract or protocol declaration without a runtime implementation.This PR updates
check_missing_super_call_for_field()to skip the check when the overriding method is abstract or belongs to aProtocoland its body kind isBodyKind::Ellipsis,BodyKind::Trivial, orBodyKind::RaiseNotImplementedError.Fixes #5431
Test Plan
Added regression tests in
pyrefly/lib/test/class_overrides.rscovering:__init__with....__init__withpass.__init__withraise NotImplementedError.__init__with....Validation: