Skip to content

[1.16 regression] determining exhaustive match on an enum with type members #19151

Description

@delfick

Hi,

I continued looking at how the codebase I work on responds to the upcoming mypy 1.16 release and I believe I found another bug

importdatetimeimportenumfromtypingimportassert_neverclassValueType(enum.Enum):
BOOLEAN=boolDATE=datetime.dateDATETIME=datetime.datetimevalue_type: ValueType=ValueType.BOOLEANmatchvalue_type:
caseValueType.BOOLEAN:
passcaseValueType.DATE:
passcaseValueType.DATETIME:
passcase _:
assert_never(value_type)

On mypy 1.16 I get this error

a.py:22: error: Argument 1 to "assert_never" has incompatible type "ValueType"; expected "Never" [arg-type]

As far as I can tell this should be correct and I'm unsure why it doesn't think I have an exhaustive match.

Your Environment

  • Mypy version used: release-1.16 (revision 96525a2, built locally with mypy_mypyc-wheels for cp312-macosx_arm64)
  • Mypy command-line flags: mypy a.py
  • Mypy configuration options from mypy.ini (and other config files): no config
  • Python version used: python3.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions