Closed
Description
Crash Report
mypy crashes when a non-generic type alias is used
https://peps.python.org/pep-0695/#generic-type-alias
Traceback
mypy --show-traceback scratchpad.py
scratchpad.py: error: INTERNAL ERROR -- Please try using mypy master on GitHub:
https://mypy.readthedocs.io/en/stable/common_issues.html#using-a-development-mypy-build
Please report a bug at https://github.com/python/mypy/issues
version: 1.7.0+dev.d440490270b643b2be333b5b27b154813f016ab6
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.12/bin/mypy", line 8, in <module>
sys.exit(console_entry())
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/__main__.py", line 15, in console_entry
main()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/main.py", line 99, in main
res, messages, blockers = run_build(sources, options, fscache, t0, stdout, stderr)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/main.py", line 178, in run_build
res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/build.py", line 189, in build
result = _build(
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/build.py", line 262, in _build
graph = dispatch(sources, manager, stdout)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/build.py", line 2885, in dispatch
graph = load_graph(sources, manager)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/build.py", line 3071, in load_graph
st = State(
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/build.py", line 1994, in __init__
self.parse_file()
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/build.py", line 2134, in parse_file
with self.wrap_context():
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/contextlib.py", line 155, in __exit__
self.gen.throw(value)
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/build.py", line 2063, in wrap_context
yield
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/build.py", line 2170, in parse_file
self.tree = manager.parse_file(
^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/build.py", line 835, in parse_file
tree = parse(source, path, id, self.errors, options=options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/parse.py", line 22, in parse
return mypy.fastparse.parse(source, fnam=fnam, module=module, errors=errors, options=options)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/fastparse.py", line 228, in parse
).visit(ast)
^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/fastparse.py", line 397, in visit
return visitor(node)
^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/fastparse.py", line 856, in visit_Module
body = self.fix_function_overloads(self.translate_stmt_list(mod.body, ismodule=True))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/fastparse.py", line 471, in translate_stmt_list
node = self.visit(stmt)
^^^^^^^^^^^^^^^^
File "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages/mypy/fastparse.py", line 395, in visit
visitor = getattr(self, method)
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'ASTConverter' object has no attribute 'visit_TypeAlias'
To Reproduce
scratchpad.py
type A = str
def myf(arg1: A):
return arg1
x = myf("hello")
print(x)
Your Environment
- Mypy version used: 1.7.0+dev.d440490270b643b2be333b5b27b154813f016ab6
- Mypy command-line flags: --show-traceback
- Mypy configuration options from
mypy.ini
(and other config files):None - Python version used: 3.12.0rc1
- Operating system and version: macOS 13.5.1 (22G90)