Document unreachability handling of return NotImplemented#20561
Merged
ilevkivskyi merged 2 commits intopython:masterfrom Jan 11, 2026
Merged
Document unreachability handling of return NotImplemented#20561ilevkivskyi merged 2 commits intopython:masterfrom
return NotImplemented#20561ilevkivskyi merged 2 commits intopython:masterfrom
Conversation
sterliakov
approved these changes
Jan 11, 2026
ilevkivskyi
approved these changes
Jan 11, 2026
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.
There is a special case about unreachability,
return NotImplemented, which we did not until now mention, which we hereby now mention in the documentation of--warn-unreachable.I also add a test to test this claimed behavior thoroughly. The current test tests its desired behavior, in a class, but the actual behavior of mypy is much broader than that, and applies all the time, it seems.
Fixes #20462. That issue is not correct anymore, as it was obsoleted by #20488. However, during its discussion @sterliakov brought up this
NotImplementededge case as something that should be documented. I think the documentation after this PR will be satisfactory by everyone's standards.Similarly, this PR closes #20558.
Theoretically, there could be further special cases of unreachability of which I am not aware, but these can be noted by later PRs if so.