Clarify --warn-unreachable behavior for pass statements#20558
Clarify --warn-unreachable behavior for pass statements#20558brovoski69 wants to merge 6 commits intopython:masterfrom
Conversation
for more information, see https://pre-commit.ci
|
This is untrue now because of #20488. The test testPassAndEllipsisUnreachable is basically your example code, but the opposite behavior. That test passes, while your example code is unfortunately not automatically typechecked so nothing complains that its expectation is wrong. For some reason, I can't replicate this on mypy-play.net to link you to some proof, even using its "master branch" setting (probably it's just not quite up-to-date). But, I pasted your example code into a local file and ran So, thanks for the effort, but we already obsoleted this! 😄 |
|
Thanks for the detailed explanation and for checking locally, which makes sense now. I wasn’t aware of the change introduced by #20488. Agreed that this documentation update is now obsolete. Thanks for the clarification, and I appreciate the review! |
…0561) 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 python#20462. That issue is not correct anymore, as it was obsoleted by python#20488. However, during its discussion @sterliakov brought up this `NotImplemented` edge 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 python#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.
This PR clarifies the documentation for the
--warn-unreachableoption by explaining that unreachablepassstatements are intentionally not reported, and adds a small example for clarity.Fixes #20462