Repository navigation
Conversation
stdlib/enum.py gives Enum, IntEnum, StrEnum, Flag and IntFlag over an EnumType metaclass, with auto(), member(), nonmember(), unique(), the FlagBoundary values and the functional form. D16-enum checks it against CPython 3.14's output. Two gaps follow from x-python running a class body before its names reach the prepared namespace: a name the body reads is still its auto() object, and a name bound twice keeps its last value instead of being refused. __members__ is a dict copy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
stdlib/enum.py, x-python's own enum, written to CPython 3.14's interface:Enum,ReprEnum,IntEnum,StrEnum,Flag,IntFlagover anEnumTypemetaclass (EnumMetaalias) andEnumDictauto(),member(),nonmember(),unique()FlagBoundarywithSTRICT,CONFORM,EJECT,KEEPEnum('Animal', 'ANT BEE')_missing_,_order_,_ignore_, pseudo-members for flag combinations, and CPython's error messagesThe README gets an
enumrow. It builds on #275 (metaclasses) and #277 (int-subclass arithmetic and class__get__).Known differences
x-python runs a class body before its names reach the namespace
__prepare__returns. That causes two gaps, both noted in the module docstring:auto()is still theautoobject when the class body itself reads it. SoAB = A | Bworks with explicit values only.Also,
__members__is a dict copy rather than a mapping proxy.Tests
tests/specs/D16-enum.spec.mdhas 6 cases. The expected output comes from CPython 3.14 with its own enum, and the same scripts give the same output with this module under CPython.Locally, on the v0.65.0 pin:
array_int_repr,class_str,fun_code_colines).🤖 Generated with Claude Code