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

[1.12 regression] New error on type[memoryView] | type[str] #17942

Closed
Christian-B opened this issue Oct 14, 2024 · 0 comments · Fixed by #17991
Closed

[1.12 regression] New error on type[memoryView] | type[str] #17942

Christian-B opened this issue Oct 14, 2024 · 0 comments · Fixed by #17991
Assignees
Labels
bug mypy got something wrong topic-pep-696 TypeVar defaults

Comments

@Christian-B
Copy link

Bug Report

new to 1.12.0
incorrect error message on union of two type one being memoryview

Complete file checked:

"""
a_type: type[memoryview] | type[str] = memoryview
"""

mypy 1.11.2 no error

mypy 1.12.0
Incompatible default for argument "a_type" (default has type "type[memoryview[Any]]", argument has type "type[memoryview[int]] | type[str]")

Your Environment
github action ubuntu various , python various

  • Mypy command-line flags:
    -no flags
  • Mypy configuration options from mypy.ini (and other config files):
  • None
  • Python version used: via github actions
    3.8, 3.9, 3.10, 3.11, 3.12 and 3.13

while
"""
a_type: type[memoryview] = memoryview
""""
Works ok!

@Christian-B Christian-B added the bug mypy got something wrong label Oct 14, 2024
@JelleZijlstra JelleZijlstra added the topic-pep-696 TypeVar defaults label Oct 14, 2024
@hauntsaninja hauntsaninja changed the title New error on type[memoryView] | type[str] [1.12 regression] New error on type[memoryView] | type[str] Oct 14, 2024
@JukkaL JukkaL self-assigned this Oct 18, 2024
JukkaL added a commit that referenced this issue Oct 18, 2024
Union type context wasn's handled previously, and it triggered false
positives, but apparently only if a type object had type var defaults.

Fixes #17942.
JukkaL added a commit that referenced this issue Oct 18, 2024
Union type context wasn't handled previously, and it triggered false
positives, but apparently only if a type object had type var defaults.

Fixes #17942.
hauntsaninja pushed a commit to hauntsaninja/mypy that referenced this issue Oct 18, 2024
Union type context wasn't handled previously, and it triggered false
positives, but apparently only if a type object had type var defaults.

Fixes python#17942.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-pep-696 TypeVar defaults
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants