Repository navigation
fix(const): OptionType.register_alias always raises 'not a registered OptionType' - #1369
Merged
Merged
Conversation
… OptionType'
- OptionType overrides register_alias: the base tested the int code against
_value2member_map_, whose keys are the formatted '{name} [{value}]'
strings, so no call could succeed.
- The member is resolved as get() resolves it: the alias name's namespace
overlaid on opt. The alias adds a name only; __members_ns__ keeps the
member, which extend_enum's throwaway __new__ call would overwrite.
- vendor template changed to match; const file re-rendered offline from the
committed payload, byte-identical.
- new test: tests/const/test_const_option_type_alias_unit.py.
Closes #1330
Owner
Author
|
Cross-review verdict on
Nits, not blocking:
|
Contributor
|
Coverage: 88.97% (unit tier, Python 3.14,
Per-file detail: the |
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.
Please follow the guide below
You will be asked some questions, please read them carefully and answer honestly
Put an
xinto all the boxes [ ] relevant to your pull request (like that [x])Use Preview tab to see how your pull request will actually look like
Searched for similar pull requests
Followed the coding style (pylint/mypy/isort with the Makefile flags on the three changed files; no new findings)
make testpasses, and a test case covers the change (only the modules listed below)Added a changelog entry — N/A, added centrally
What is the purpose of your pull request?
fix— corrects a defectCloses #1330
OptionType.register_aliasoverrides the base, which looked theintcode up among the formatted'{name} [{value}]'keys. Namespace rule:valueresolves in the alias name's prefix namespace overlaid onopt, asget()does.__members_ns__is restored afterextend_enum, whose throwaway__new__call otherwise overwrites the member there (measured). Vendor template changed; const re-rendered offline from the committed payload, byte-identical.corekit/enum.pyuntouched.register_alias(1, 'opt_comment_alias')ValueErroropt_commentregister_alias(2, 'if_label')ValueErrorif_name;__members_ns__['if'][2]stillif_nameregister_alias(0x7ABC, 'if_x')ValueErrorValueErrorTests: new
test_const_option_type_alias_unit.py7 passed; 5 of 7 fail on theorigin/mainconst file (the two refusal cases pin guards that already held). Also green:test_register_roundtrip_unit8,test_const_registry_protocol74,test_const_enum_no_mint68,test_pcapng_unit97,tests/project389 passed / 1 skipped,run_unittest_leg.py const499 tests, 0 failures.