torch-nn-functional-mypy-bug-when-torchvision-installed
Open
Nobody has claimed this yet.
crash
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
description
mypy crashes on a file that imports torch.nn.functional when torchvision is installed in conjunction with --follow-imports=skip flag.
traceback
$ mypy --show-traceback --follow-imports=skip harmless.py
Traceback (most recent call last):
File "/home/eytan/miniconda3/envs/mypy/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/home/eytan/miniconda3/envs/mypy/lib/python3.10/site-packages/mypy/__main__.py", line 15, in console_entry
main()
File "mypy/main.py", line 103, in main
File "mypy/main.py", line 187, in run_build
File "mypy/build.py", line 193, in build
File "mypy/build.py", line 268, in _build
File "mypy/build.py", line 2950, in dispatch
File "mypy/build.py", line 3348, in process_graph
File "mypy/build.py", line 3475, in process_stale_scc
File "mypy/build.py", line 2507, in write_cache
File "mypy/build.py", line 1568, in write_cache
File "mypy/nodes.py", line 390, in serialize
File "mypy/nodes.py", line 4012, in serialize
File "mypy/nodes.py", line 3949, in serialize
File "mypy/nodes.py", line 3374, in serialize
File "mypy/types.py", line 671, in serialize
File "mypy/types.py", line 2428, in serialize
File "mypy/types.py", line 1451, in serialize
File "mypy/types.py", line 671, in serialize
File "mypy/types.py", line 3093, in serialize
AssertionError: Internal error: unresolved placeholder type None
Minimal example repo with instructions
- repository here
environment
- OS: Ubuntu 22.04.4
- miniconda: 24.5.0
- mypy: 1.11.1
reproduced in:
- Python:
3.10,3.11,3.12
full pip freezes in example repo
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked minimal example repository and run the reported mypy command using --follow-imports=skip with torch and torchvision installed. Trace the cache-writing path named in mypy/build.py, mypy/nodes.py, and mypy/types.py, then verify that the command completes without the unresolved placeholder type assertion.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100