Extending `TraverserVisitor` causes `TypeError: interpreted classes cannot inherit from compiled traits`
オープン
まだ誰も着手していません。
bug
- 主要言語
- Python
- スター
- 20.6k
- フォーク
- 3.3k
- PR マージ指標
- PR 指標を取得中
説明
Bug Report
Plugin code cannot extend any of the Visitor classes
To Reproduce
from mypy.nodes import IndexExpr, MypyFile
from mypy.plugin import Plugin
from mypy.traverser import TraverserVisitor
def plugin(_: str) -> type[Plugin]:
return ReproducerPlugin
class ReproducerPlugin(Plugin):
def get_additional_deps(self, file: MypyFile) -> list[tuple[int, str, int]]:
class IndexVisitor(TraverserVisitor):
def visit_index_expr(self, ie: IndexExpr, /) -> None:
print(ie)
file.accept(IndexVisitor())
Expected Behavior
It not crash
Actual Behavior
[ERROR ] An un-handled exception was caught by Salt's global exception handler:
TypeError: interpreted classes cannot inherit from compiled traits
Traceback (most recent call last):
File "venv/bin/mypy", line 8, in <module>
sys.exit(console_entry())
~~~~~~~~~~~~~^^
File "venv/lib/python3.13/site-packages/mypy/__main__.py", line 15, in console_entry
main()
~~~~^^
File "mypy/main.py", line 127, in main
File "mypy/main.py", line 211, in run_build
File "mypy/build.py", line 191, in build
File "mypy/build.py", line 267, in _build
File "mypy/build.py", line 2886, in dispatch
File "mypy/build.py", line 3072, in load_graph
File "mypy/build.py", line 1994, in __init__
File "mypy/build.py", line 2292, in compute_dependencies
File "mypy/plugin.py", line 845, in get_additional_deps
File "plugin/__init__.py", line 16, in get_additional_deps
file.accept(IndexVisitor())
~~~~~~~~~~~~^^
TypeError: interpreted classes cannot inherit from compiled traits
Your Environment
LOG: Mypy Version: 1.17.0
LOG: Config File: pyproject.toml
LOG: Configured Executable: venv/bin/python3.13
LOG: Current Executable: venv/bin/python3.13
LOG: Cache Dir: .mypy_cache
LOG: Compiled: True
LOG: Exclude: []
LOG: Found source: BuildSource(path='test.py', module='test', has_text=False, base_dir='.', followed=False)
LOG: Metadata abandoned for test: options differ
LOG: Metadata not found for test
LOG: Parsing test.py (test)
LOG: Build finished in 0.013 seconds with 1 modules, and 0 errors
from pyproject.toml:
[tool.mypy]
plugins = ["pydantic.mypy", "plugin"]
strict = true
namespace_packages = true
mypy_path = ".mypy-stubs/"
scripts_are_modules = true
- Python version used: 3.13
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された Python 3.13 の再現プログラムをコンパイル済みの mypy で実行し、次に mypy/traverser.py の TraverserVisitor と、mypy/plugin.py に示されているプラグイン読み込み経路を調査します。解釈されたサブクラスの初期化に失敗する理由を追跡し、再現プログラムが TypeError なしで完了することを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- devtools
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 42/100