-
-
Notifications
You must be signed in to change notification settings - Fork 36
const: bring the 16 bespoke registries onto EnumRegistry, after fixing the base's str-key dispatch #860
Copy link
Copy link
Closed
Labels
constRegenerated IANA or vendor constant tables; members keep their numeric valuesRegenerated IANA or vendor constant tables; members keep their numeric valuesdesignA design or decision issue: a pattern being decided rather than a defect or a requestA design or decision issue: a pattern being decided rather than a defect or a requestenhancementIssues requesting a new capability (set by the feature request template)Issues requesting a new capability (set by the feature request template)refactorRestructuring for its own sake — neither a fix nor a new capability (refactor: prefix)Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)
Milestone
Description
Activity
Metadata
Metadata
Assignees
Labels
constRegenerated IANA or vendor constant tables; members keep their numeric valuesRegenerated IANA or vendor constant tables; members keep their numeric valuesdesignA design or decision issue: a pattern being decided rather than a defect or a requestA design or decision issue: a pattern being decided rather than a defect or a requestenhancementIssues requesting a new capability (set by the feature request template)Issues requesting a new capability (set by the feature request template)refactorRestructuring for its own sake — neither a fix nor a new capability (refactor: prefix)Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)
Projects
- StatusShow more project fieldsDone
Is your feature request related to a problem? Please describe.
Filed per @JarryShaw's ruling on #842: "Take (1) then and file tracking for the remaining work and keep on working."
#842 is closed as done at 111 of 127 const enum classes inheriting
EnumRegistry. This tracks the remaining 16.They divide into two groups, measured on
main:Each defines its own
__new__and its own hand-writtenget, so none sharespcapkit/vendor/default.py's template —which is why #858 could not sweep them up.
The blocker is real, not merely bookkeeping. The base
getdispatches onisinstance(key, str)and itsstrbranch never falls back to the value path. So on a
StrEnumregistry a valid value that is not a name wouldstart raising
KeyErrorwhere the bespokegetresolved it. That was measured during #858's review on a realEnumRegistry+StrEnumfixture, not hypothesised.Describe the solution you'd like
Two steps, in order:
str-key dispatch so aStrEnumregistry can resolve a key that is a valid value but not aname — try the name path, then fall through to the value path rather than raising.
tests/consthas noStrEnum-valued registry on the base today, so this needs a fixture as well as a fix.__new__earns an exemption.ftp/return_codeandhttp/status_codeareIntEnumand unaffected by (1), so they could go first.Describe alternatives you've considered
Converting them without (1), which #858's review showed regresses
StrEnumvalue lookups. Rejected.Leaving all 16 permanently bespoke. Defensible — they genuinely differ — but it leaves
get/get_all/register/register_aliasunavailable on four publicStrEnumregistries includingAppType, which is the one most likely tobe reached for.
Additional context
A second, independent item for the same 16, from #859's review:
ftp/return_code.py:284,299andhttp/status_code.py:250,265still carry their own-1-as-no-default convention (if default == -1: raise). After#859 the 111 treat
-1as an ordinary value, so the repo will hold two meanings for a literal-1default (plusa third, value-to-mint, at
pcapng/option_type.py:201and six sites inprotocols/). Harmonising that belongs heretoo.
Related: #842 (closed, the 111), #858 (the template move), #859 (the
NO_DEFAULTsentinel), #775 (the minting tier).