Repository navigation
Mark code after breakless statically true loops as unreachable - #5324
Open
asukaminato0721 wants to merge 1 commit into
Open
asukaminato0721 wants to merge 1 commit into
asukaminato0721 wants to merge 1 commit into
Conversation
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D126824565. (Because this pull request was imported automatically, there will not be any future comments.) |
|
Diff from mypy_primer, showing the effect of this PR on open source code: ============================================================
SUMMARY
============================================================
Total: +5 new errors, -2 fixed errors
By preset: +5/-2 (default), +5/-2 (strict)
Projects with changes (4):
psycopg: +2 -0
manticore: +1 -2
poetry: +1 -0
cvxpy: +1 -0
============================================================
FULL DIFF DETAILS
------------------------------------------------------------
psycopg (https://github.com/psycopg/psycopg)
+ ERROR psycopg/psycopg/types/multirange.py:333:9-19: This code is unreachable [unreachable]
+ ERROR tests/pq/test_pgconn.py:44:5-46:61: This code is unreachable [unreachable]
manticore (https://github.com/trailofbits/manticore)
+ ERROR tests/auto_generators/trace.py:174:1-46: This code is unreachable [unreachable]
- ERROR tests/ethereum/test_general.py:1723:26-32: `result` may be uninitialized [unbound-name]
- ERROR tests/ethereum/test_general.py:1779:26-32: `result` may be uninitialized [unbound-name]
poetry (https://github.com/python-poetry/poetry)
+ ERROR src/poetry/utils/authenticator.py:301:9-74: This code is unreachable [unreachable]
cvxpy (https://github.com/cvxpy/cvxpy)
+ ERROR cvxpy/utilities/power_tools.py:610:5-69: This code is unreachable [unreachable] |
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
Code after a statically true loop without a
breakis unreachable. Record flow termination after these loops, including retry loops that can exit only throughreturnor an exception.Preserve exception termination so an enclosing context manager can suppress it. Keep environment-dependent loop conditions from producing unreachable warnings in code that can execute in another Python environment.
This changes the default-enabled unreachable-code diagnostic. It is independent of the attribute initialization check in #4326. Direct tests cover retry loops, infinite loops, environment-dependent conditions, and suppressed exceptions.
Test Plan