Skip to content

Conversation

wyattscarpenter
Copy link
Contributor

Achieves a todo, enabling warn_unreachable = True for mypyc and all other files as well

@wyattscarpenter
Copy link
Contributor Author

wyattscarpenter commented May 8, 2025

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.

@sterliakov
Copy link
Collaborator

Wow, only one hit? That should be easy to resolve...

@wyattscarpenter
Copy link
Contributor Author

wyattscarpenter commented May 10, 2025

@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.

JukkaL pushed a commit that referenced this pull request Jun 5, 2025
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.

@wyattscarpenter
Copy link
Contributor Author

Hmm, another hit. I guess it was masked or subsequently developed or something...
Running the self-check on my computer, with python 3.9, doesn't produce this problem, even with --python-version 3.9 🤔. So I guess it's an actual python language behavior change...

@wyattscarpenter
Copy link
Contributor Author

wyattscarpenter commented Jun 7, 2025

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.

@brianschubert
Copy link
Member

Even after installing python 3.9 I can't reproduce this. Odd.

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)

I'll try merging again once another commit hits master, in case this was a fluke.

quick git tip: you can also tickle the CI by pushing an empty commit with git commit --allow-empty

This comment has been minimized.

@wyattscarpenter
Copy link
Contributor Author

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.

@JukkaL
Copy link
Collaborator

JukkaL commented Aug 15, 2025

if isinstance(ops, PrimitiveDescription):

This and the following line can probably be removed, since the isinstance check can never be true.

@sterliakov
Copy link
Collaborator

Let's remove that and try to merge this before we introduce another unreachable block:)

JukkaL added a commit that referenced this pull request Aug 15, 2025
JukkaL added a commit that referenced this pull request Aug 15, 2025
@JukkaL
Copy link
Collaborator

JukkaL commented Aug 15, 2025

The unreachable code is now removed on master.

This comment has been minimized.

@wyattscarpenter
Copy link
Contributor Author

wyattscarpenter commented Aug 15, 2025

Ok, well, now it's back to the isinstance(chunk, list) unreachable error from before.

(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.

This comment has been minimized.

Copy link
Contributor

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__

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

Successfully merging this pull request may close these issues.

4 participants