-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrong
Description
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
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong