Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mypy Self Checking Should Enable --warn-unreachable #18079

Open
davidhalter opened this issue Oct 31, 2024 · 5 comments
Open

Mypy Self Checking Should Enable --warn-unreachable #18079

davidhalter opened this issue Oct 31, 2024 · 5 comments
Labels
refactoring Changing mypy's internals topic-reachability Detecting unreachable code

Comments

@davidhalter
Copy link

Is it intentional that --warn-unreachable is not used while self checking in the CI? (with mypy_self_check.ini)

I have recently realized that this is not turned on and it feels a bit strange. There are about 39 errors when running with --warn-unreachable and it brings up a few questionable things like https://github.com/python/mypy/blob/master/mypy/test/testpep561.py#L180.

@sobolevn told me to create this issue in #18076 (comment)

@davidhalter davidhalter added the bug mypy got something wrong label Oct 31, 2024
@JelleZijlstra JelleZijlstra added refactoring Changing mypy's internals and removed bug mypy got something wrong labels Oct 31, 2024
@sobolevn
Copy link
Member

Please, feel free to send a PR.

@AlexWaygood AlexWaygood added the topic-reachability Detecting unreachable code label Nov 1, 2024
@AlexWaygood
Copy link
Member

I tried this in the past and found that it caused too many false-positive errors in the self-check at that point to make it feasible. For example, branches under if sys.platform == "win32" tests were thought to be unreachable if checking with --platform=linux (strictly speaking that's true, but it's very annoying and not at all useful to have that cause the check to fail).

The reachability heuristics mypy uses may have improved since then, though; it was a while ago that I tried it.

@davidhalter
Copy link
Author

For example, branches under if sys.platform == "win32" tests were thought to be unreachable if checking with --platform=linux

I don't think this is the case anymore. I also haven't had any problems with it in my personal projects and going randomly through 8 of the 39 issues raised above, Mypy seems to be correct about all of them except maybe one that is related to mypy_extensions.trait. I'm not sure I have the time right now, but I really believe that this would be worth it.

@JelleZijlstra
Copy link
Member

I think turning this option on for mypy itself would be a good way to dogfood it and force ourselves to make sure it is reliable.

@AlexWaygood
Copy link
Member

I absolutely agree that this would be worth it if it is possible! I wasn't trying to dissuade anybody, was just giving context on something I previously tried a while back :-)

And, it may well be that the check has improved significantly since I tried it last!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactoring Changing mypy's internals topic-reachability Detecting unreachable code
Projects
None yet
Development

No branches or pull requests

4 participants