Closed
Description
Bug Report
There is a bug that makes it impossible to typecheck any Python application/library that has an import of the asyncssh package. However, typechecking asyncssh directly doesn't result in this bug. (See below, for a sort of reproducer).
The error looks like this:
Traceback (most recent call last):
File "/home/jonathan/.pyenv/versions/env/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/__main__.py", line 15, in console_entry
main()
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/main.py", line 95, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/main.py", line 174, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/build.py", line 194, in build
result = _build(
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/build.py", line 277, in _build
graph = dispatch(sources, manager, stdout)
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/build.py", line 2923, in dispatch
process_graph(graph, manager)
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/build.py", line 3320, in process_graph
process_stale_scc(graph, scc, manager)
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/build.py", line 3443, in process_stale_scc
graph[id].write_cache()
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/build.py", line 2504, in write_cache
new_interface_hash, self.meta = write_cache(
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/build.py", line 1574, in write_cache
data = tree.serialize()
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/nodes.py", line 377, in serialize
"names": self.names.serialize(self._fullname),
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/nodes.py", line 3841, in serialize
data[key] = value.serialize(fullname, key)
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/nodes.py", line 3778, in serialize
data["node"] = self.node.serialize()
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/nodes.py", line 3514, in serialize
"target": self.target.serialize(),
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/types.py", line 2072, in serialize
"ret_type": self.ret_type.serialize(),
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/types.py", line 605, in serialize
"values": [v.serialize() for v in self.values],
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/types.py", line 605, in <listcomp>
"values": [v.serialize() for v in self.values],
File "/home/jonathan/.pyenv/versions/3.9.13/envs/env/lib/python3.9/site-packages/mypy/types.py", line 2876, in serialize
assert False, f"Internal error: unresolved placeholder type {self.fullname}"
AssertionError: Internal error: unresolved placeholder type None
To Reproduce
Install asyncssh
, then create a Python file with only this import and typecheck that file.
import asyncssh
Or:
mypy -c 'import asyncssh'
I tried to reduce the code surface as much as possible. Removing every file within asyncssh, except py.typed
and __init__.py
, and then write the following in __init__.py
:
from typing import TypeVar, Callable
T = TypeVar('T', 'A', 'B')
Func = Callable[[], T]
With the above snippet it still happens.
Your Environment
- Mypy version used: 1.0.0
- Mypy command-line flags:
--strict
- Mypy configuration options from
mypy.ini
(and other config files): / - Python version used: 3.9.13
cc: @ronf