Skip to content

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

Description

@Christian-B

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!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugmypy got something wrongtopic-pep-696TypeVar defaults

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions