Skip to content

Conformance: broaden enum-expansion tests - #2324

Open
tapetersen wants to merge 2 commits into
python:mainfrom
tapetersen:enums-expansion-full-union-assignability
Open

Conformance: broaden enum-expansion tests#2324
tapetersen wants to merge 2 commits into
python:mainfrom
tapetersen:enums-expansion-full-union-assignability

Conversation

@tapetersen

Copy link
Copy Markdown

The spec's Enum Literal Expansion section states that a type checker
should treat a complete union of all literal members as equivalent to
the enum type. Add test to cover cases failing in some checkers.

Also refreshes all three quoted spec passages, which had drifted from
the section as rewritten in a6eeccf ("new type system concepts section",

Fixes #2323.

@python-cla-bot

python-cla-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

CLA signed

The spec's Enum Literal Expansion section states that a type checker
should treat a complete union of all literal members as equivalent to
the enum type. Add test to cover cases failing in some checkers.

Also refreshes all three quoted spec passages, which had drifted from
the section as rewritten in a6eeccf ("new type system concepts section",

Reported in python#2323.
Four checkers accept the full-literal-union equivalency and are
unaffected: mypy, pyrefly, pycroscope and ty (mypy and ty remain
"Partial" for the pre-existing `Flag` narrowing gap only). Three drop
from "Pass" to "Partial":

* pyright and zuban reject both the assignment and the `assert_type`.
* basilisk rejects only the assignment; it reports the `assert_type` in
  test1 as redundant, so it does treat the two types as equivalent
  there.
@tapetersen
tapetersen force-pushed the enums-expansion-full-union-assignability branch from 36acade to 43b2427 Compare July 30, 2026 12:31
@srittau srittau added the topic: conformance tests Issues with the conformance test suite label Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: conformance tests Issues with the conformance test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

enums_expansion.py test3 misses cases of the union-of-all-member = enum equivalency

3 participants