Daemon crashes with a decorator returning `Generic/Protocol`, decorated method returning `Self`, and an undefined symbol
オープン
まだ誰も着手していません。
crash
topic-daemon
topic-fine-grained-incremental
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
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
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供されたダミープロジェクトを dmypy で実行し、次に mypy/dmypy_server.py と mypy/server/update.py の traceback のパスを調べます。特に、インクリメンタルな依存関係の伝播を確認してください。utils.py を変更した後の 2 回目の dmypy 実行を再現します。daemon がクラッシュもハングもせず、チェックが正常に完了すれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 42/100