Skip to content

Avoid false unreachable and redundant-expr warnings in loops more robustly and efficiently, and avoid multiple revealed type notes for the same line. #19118

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

tyralla
Copy link
Collaborator

@tyralla tyralla commented May 20, 2025

Fixes #18606
Closes #18511
Improves #18991

This change is an improvement over 9685171. Besides fixing the regression reported in #18606 and removing the duplicates reported in #18511, it should significantly reduce the performance regression reported in #18991. At least running Measure-command {python runtests.py self} on my computer (with removed cache) is 10 % faster.

tyralla and others added 2 commits May 20, 2025 07:12
… robustly and efficiently, and avoid multiple `revealed type` notes for the same line.

This change is an improvement over 9685171.  Besides fixing the regression reported in python#18606 and removing the duplicates reported in python#18511, it should significantly reduce the performance regression reported in python#18991.  At least running `Measure-command {python runtests.py self}` on my computer (with removed cache) is 10 % faster.
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@tyralla tyralla requested a review from JukkaL May 20, 2025 06:58
@tyralla
Copy link
Collaborator Author

tyralla commented May 20, 2025

@JukkaL: I thought that later responses to reveal_type are always better than earlier ones. However, this is not the case for testNewRedefineTryStatement test case. Maybe the most general approach would be to collect all the union items of the individual responses and to combine them in the final note. I could try this, if you think it's a good way to go.

Alternatively, I could just remove the reveal_type part of this pull request, as it seems less important than the other two addressed issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant