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

Stubgen crashes on new Python 3.10 union syntax #14533

Closed
KapJI opened this issue Jan 27, 2023 · 0 comments · Fixed by #14557
Closed

Stubgen crashes on new Python 3.10 union syntax #14533

KapJI opened this issue Jan 27, 2023 · 0 comments · Fixed by #14557

Comments

@KapJI
Copy link

KapJI commented Jan 27, 2023

Crash Report

It works in some cases e.g. with cast() function but here with TypeVar it crashes.

Mypy accepts this file with no errors.

Traceback

  File "mypy/stubgen.py", line 1858, in main
  File "mypy/stubgen.py", line 1701, in generate_stubs
  File "mypy/stubgen.py", line 1643, in generate_stub_from_ast
  File "mypy/nodes.py", line 373, in accept
  File "mypy/stubgen.py", line 643, in visit_mypy_file
  File "mypy/traverser.py", line 114, in visit_mypy_file
  File "mypy/nodes.py", line 1301, in accept
  File "mypy/stubgen.py", line 1006, in visit_assignment_stmt
  File "mypy/stubgen.py", line 1117, in process_typealias
  File "mypy/nodes.py", line 1841, in accept
  File "mypy/stubgen.py", line 362, in visit_call_expr
TypeError: str object expected; got None

To Reproduce

from __future__ import annotations

from typing import TypeVar

T = TypeVar("T", bound=str | None)

Your Environment

  • Mypy version used: 0.991
  • Mypy command-line flags: stubgen test.py
  • Mypy configuration options from mypy.ini (and other config files):
  • Python version used: 3.10.9
  • Operating system and version: macOS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants