-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Enable warn_unreachable = True for mypyc
and all other files as well
#19050
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
base: master
Are you sure you want to change the base?
Enable warn_unreachable = True for mypyc
and all other files as well
#19050
Conversation
I am now waiting on mypyc/mypyc#1101 to be resolved to finish this issue, after which I will have to rebase this branch onto master to get the resolution. |
This comment has been minimized.
This comment has been minimized.
Wow, only one hit? That should be easy to resolve... |
@stanislavlevin, yep! Only one hit for this project 🥳! Unfortunately (so to speak), deciding what to do about that is best left to people more familiar with mypyc than me. I could simply comment out this code, which I might do eventually, but if someone with a better idea about what it should do comes along, I will defer to them. |
Supplements #19050. The old version did certainly contain unreachable code, as otherwise that branch would have crashed, there is no `type_args` attribute. This block was introduced in #17027 - probably as a future-proof expansion to generic primitive operations, but it makes no sense now, this logic can be added back should it become necessary.
This comment has been minimized.
This comment has been minimized.
Hmm, another hit. I guess it was masked or subsequently developed or something... |
Even after installing python 3.9 I can't reproduce this. Odd. I'll try merging again once another commit hits master, in case this was a fluke. |
FWIW, I can reproduce this locally in a fresh 3.9 venv: $ python --version
Python 3.9.23
$ python -m mypy --config-file mypy_self_check.ini misc --exclude misc/sync-typeshed.py
misc/analyze_cache.py:44: error: Statement is unreachable [unreachable]
elif isinstance(chunk, list):
^
misc/analyze_cache.py:44: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-unreachable for more info
misc/analyze_cache.py:96: error: Statement is unreachable [unreachable]
return chunk
^~~~~~~~~~~~
misc/analyze_cache.py:127: error: Statement is unreachable [unreachable]
return chunk
^~~~~~~~~~~~
Found 3 errors in 1 file (checked 17 source files)
quick git tip: you can also tickle the CI by pushing an empty commit with |
This comment has been minimized.
This comment has been minimized.
Well, now time has passed and we're down to one different problem, apparently: mypyc/test/test_cheader.py:35: error: Subclass of "list[PrimitiveDescription]" and "PrimitiveDescription" cannot exist: "PrimitiveDescription" is final [unreachable]
if isinstance(ops, PrimitiveDescription):
^~~
mypyc/test/test_cheader.py:35: note: See https://mypy.rtfd.io/en/stable/_refs.html#code-unreachable for more info
mypyc/test/test_cheader.py:36: error: Statement is unreachable [unreachable]
ops = [ops]
^~~~~~~~~~~
Found 2 errors in 1 file (checked 313 source files) |
This comment has been minimized.
This comment has been minimized.
This and the following line can probably be removed, since the |
Let's remove that and try to merge this before we introduce another unreachable block:) |
The unreachable code is now removed on master. |
This comment has been minimized.
This comment has been minimized.
Ok, well, now it's back to the (Edit: assuming this doesn't clear up on its own by the next time I look into it, I'll probably just throw in a couple type-ignores with TODOs next to them. Better than not having this analysis run at all...) |
This comment has been minimized.
This comment has been minimized.
…that can never be gotten
This comment has been minimized.
This comment has been minimized.
…reachable and silence it
for more information, see https://pre-commit.ci
This comment has been minimized.
This comment has been minimized.
Rely on pre-commit to fix this formatting
for more information, see https://pre-commit.ci
Diff from mypy_primer, showing the effect of this PR on open source code: AutoSplit (https://github.com/Toufool/AutoSplit)
- File "/tmp/mypy_primer/mypy_old/venv/bin/mypy", line 7, in <module>
+ File "/tmp/mypy_primer/mypy_new/venv/bin/mypy", line 7, in <module>
- File "/tmp/mypy_primer/mypy_old/venv/lib/python3.13/site-packages/mypy/__main__.py", line 15, in console_entry
+ File "/tmp/mypy_primer/mypy_new/venv/lib/python3.13/site-packages/mypy/__main__.py", line 15, in console_entry
- File "/tmp/mypy_primer/mypy_old/venv/lib/python3.13/site-packages/mypy/main.py", line 127, in main
+ File "/tmp/mypy_primer/mypy_new/venv/lib/python3.13/site-packages/mypy/main.py", line 127, in main
- File "/tmp/mypy_primer/mypy_old/venv/lib/python3.13/site-packages/mypy/main.py", line 211, in run_build
+ File "/tmp/mypy_primer/mypy_new/venv/lib/python3.13/site-packages/mypy/main.py", line 211, in run_build
- File "/tmp/mypy_primer/mypy_old/venv/lib/python3.13/site-packages/mypy/build.py", line 196, in build
+ File "/tmp/mypy_primer/mypy_new/venv/lib/python3.13/site-packages/mypy/build.py", line 196, in build
- File "/tmp/mypy_primer/mypy_old/venv/lib/python3.13/site-packages/mypy/build.py", line 272, in _build
+ File "/tmp/mypy_primer/mypy_new/venv/lib/python3.13/site-packages/mypy/build.py", line 272, in _build
- File "/tmp/mypy_primer/mypy_old/venv/lib/python3.13/site-packages/mypy/build.py", line 2946, in dispatch
+ File "/tmp/mypy_primer/mypy_new/venv/lib/python3.13/site-packages/mypy/build.py", line 2946, in dispatch
- File "/tmp/mypy_primer/mypy_old/venv/lib/python3.13/site-packages/mypy/build.py", line 3346, in process_graph
+ File "/tmp/mypy_primer/mypy_new/venv/lib/python3.13/site-packages/mypy/build.py", line 3346, in process_graph
- File "/tmp/mypy_primer/mypy_old/venv/lib/python3.13/site-packages/mypy/build.py", line 3475, in process_stale_scc
+ File "/tmp/mypy_primer/mypy_new/venv/lib/python3.13/site-packages/mypy/build.py", line 3475, in process_stale_scc
- File "/tmp/mypy_primer/mypy_old/venv/lib/python3.13/site-packages/mypy/build.py", line 2493, in write_cache
+ File "/tmp/mypy_primer/mypy_new/venv/lib/python3.13/site-packages/mypy/build.py", line 2493, in write_cache
- File "/tmp/mypy_primer/mypy_old/venv/lib/python3.13/site-packages/mypy/cache.py", line 28, in __init__
+ File "/tmp/mypy_primer/mypy_new/venv/lib/python3.13/site-packages/mypy/cache.py", line 28, in __init__
|
Achieves a todo, enabling warn_unreachable = True for
mypyc
and all other files as well