Daemon crashes with a decorator returning `Generic/Protocol`, decorated method returning `Self`, and an undefined symbol
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
Crash Report & To Reproduce
With a relatively simple reproducer and small example, this causes a crash. Anything larger than a small example will cause dmypy to hang.
- Set up the following dummy project
cd projectdmypy run- Change
project/src/pkg/utils.py(e.g. adda = 1234at the end of this file) dmypy runagain (crashes)
Dummy project:
project/
src/
pkg/
__init__.py (blank)
module.py
utils.py
mypy.ini
-
mypy.ini
[mypy] files = src/ -
module.py
from typing_extensions import Self from pkg.utils import deco var = UNDEFINED_SYMBOL class A: @deco def mymethod(self) -> Self: ... -
utils.py
from collections.abc import Callable from typing import Protocol, TypeVar from typing_extensions import ParamSpec _P = ParamSpec("_P") _R_co = TypeVar("_R_co", covariant=True) _T = TypeVar("_T") def deco(f: Callable[_P, _T], /) -> _Method[_P, _T]: ... class _Method(Protocol[_P, _R_co]): ...
Traceback
Runtime error from non-compiled mypy is below on master (commit https://github.com/python/mypy/commit/842a8fdcaa711c92c1067d373098844eb7d1ab57)
Daemon crashed!
Traceback (most recent call last):
File ".../python3.13/site-packages/mypy/dmypy_server.py", line 237, in serve
resp = self.run_command(command, data)
File ".../python3.13/site-packages/mypy/dmypy_server.py", line 286, in run_command
ret = method(self, **data)
File ".../python3.13/site-packages/mypy/dmypy_server.py", line 354, in cmd_run
return self.check(sources, export_types, is_tty, terminal_width)
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File ".../python3.13/site-packages/mypy/dmypy_server.py", line 433, in check
messages = self.fine_grained_increment_follow_imports(
sources, explicit_export_types=export_types
)
File ".../python3.13/site-packages/mypy/dmypy_server.py", line 640, in fine_grained_increment_follow_imports
messages = fine_grained_manager.update(changed, [], followed=True)
File ".../python3.13/site-packages/mypy/server/update.py", line 286, in update
changed_modules = propagate_changes_using_dependencies(
self.manager,
...<5 lines>...
self.processed_targets,
)
File ".../lib/python3.13/site-packages/mypy/server/update.py", line 857, in propagate_changes_using_dependencies
raise RuntimeError("Max number of iterations (%d) reached (endless loop?)" % MAX_ITER)
RuntimeError: Max number of iterations (1000) reached (endless loop?)
Your Environment
- Mypy version used: 1.18.2, master
- Mypy command-line flags: None
- Mypy configuration options from
mypy.ini(and other config files): None - Python version used: 3.13
- Operating system and version: Pop OS! 22.04 LTS
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 by running the provided dummy project with dmypy, then inspect the traceback paths in mypy/dmypy_server.py and mypy/server/update.py, especially incremental dependency propagation. Reproduce the second dmypy run after changing utils.py; done means the daemon neither crashes nor hangs and the check completes normally.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 42/100