Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'ASTConverter' object has no attribute 'visit_TypeAlias' and Python 3.12.0rc1 #16011

Closed
ChrisGojlo opened this issue Sep 1, 2023 · 1 comment · Fixed by #16013
Labels

Comments

@ChrisGojlo
Copy link

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)
@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Sep 1, 2023

mypy doesn't yet support PEP 695. I'll make this have a better error in the meantime though. Closing as duplicate of #15238

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Sep 1, 2023
hauntsaninja added a commit to hauntsaninja/mypy that referenced this issue Sep 1, 2023
hauntsaninja added a commit to hauntsaninja/mypy that referenced this issue Sep 1, 2023
JelleZijlstra pushed a commit that referenced this issue Sep 2, 2023
Mypy does not yet support PEP 695

Fixes #16011, linking #15238
JukkaL pushed a commit that referenced this issue Oct 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants