fix(corekit): reparent the unblocked non-registry enums onto EnumLookup (#877) - #921
Conversation
db5953a to
21c9b28
Compare
|
Cross-review on Opus returned NEEDS CHANGES (author was Sonnet). Both findings were prose, both are now fixed — new head The code was sound; two comments asserted something measurement refutes. I re-derived both myself on What was wrong. The delegation is exception-compatible for every key the signature admits (
No caller can reach any of it: the only live sites are Also corrected: the pre-fix failure count is 31 Verified after the amend: 51 tests across |
|
GOOD TO GO at head The two load-bearing claims, measured independently:
Worth recording from the reviewer, correcting its own earlier framing: the template is a Behaviour is unchanged from One item remains UNVERIFIED and is not blocking: the Unpublished and unmerged — yours to merge. Note the merge-order constraint recorded on #922. |
|
We may want to revise if their overrides after subclassing |
|
Ruling recorded, verbatim:
Measured before answering, on
So neither override is redundant — but each is down to a small, nameable job. Deleting either would be a public behaviour change, not a cleanup: a name miss would start raising Which leaves a real design question, and it is yours: is the Labelled |
|
Either |
…up (#877) Phase 2 of #877, the 11 classes across 8 files not held by #913/#904: TransportProtocol, FinalisedState, Completion, ftp.Type, httpv1.Type, Criticality, PDUKind, PacketDirection, PacketReception, WireGuardKeyLabel, and FrameType.Flags (carrying its 6 per-frame subclasses transitively). Each now mixes in EnumLookup ahead of its enum base for the shared get/get_all contract. TransportProtocol and Criticality already had their own get, both as a staticmethod against EnumLookup.get's classmethod (the #908/#915 trap). Both are now classmethods delegating to super().get(), keeping only what the base does not reproduce -- TransportProtocol's case-fold and no-mint refusal, Criticality's case-sensitive miss -- each re-raised as the ValueError callers already depend on rather than the base's KeyError. Each gained a default parameter forwarded to the base, since dropping one the base declares is a real classmethod-override violation under mypy. Updated test_const_enum_get.py's exclusion set for TransportProtocol's new default, and added test_enum_lookup_reparent_877_unit.py pinning the re-parenting, both preserved overrides, and no member-table growth.
21c9b28 to
3e7d73d
Compare
|
Ruling recorded, verbatim:
Measured on Python 3.14.7, so the shape the ruling selects is concrete: Two consequences, and one gap I did not expect:
Filed as #923 ( Removing Also rebased onto |
|
So the overloads are still legit? Or they will be fixe/updated in #923? |
|
Both: legitimate as shipped here, then reduced in #923. Measured rather than assumed. Legitimate now. Each override still does something the inherited base does not, so nothing in this PR ships dead code:
#923 removes the conversion, and that is what changes each of them. Under the ruling — stdlib shape,
The only thing lost by deleting it is the narrower One thing I went looking for and did not find, so it is not a defect to fix: I expected the So: merge this as-is, and #923 does the reduction. I have recorded the above in #923's scope so the two-into-one shrink is not rediscovered there. |
Please follow the guide below
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
fix-- corrects a defectDescription of your pull request and other information
Phase 2 of #877, the owner's ruling to reparent every non-registry enum onto
EnumLookup. This covers the 11 classes across 8 files not held by #913 or #904:TransportProtocol,FinalisedState,Completion,ftp.Type,httpv1.Type,Criticality,PDUKind,PacketDirection,PacketReception,WireGuardKeyLabel, andFrameType.Flags(which carries its 6 concrete per-frame subclasses transitively -- verified at runtime, not assumed).TransportProtocolandCriticalityalready defined their ownget, both as astaticmethodagainstEnumLookup.get'sclassmethod-- the exact trap #908 hit and #915 fixed. Both are nowclassmethods delegating tosuper().get(), keeping only the behaviour the base doesn't reproduce (case-folding and the PR #836 no-mint refusal forTransportProtocol; case-sensitivity forCriticality), each still raising theValueErrorcallers already depend on rather than the base'sKeyError. Each gained adefaultparameter forwarded verbatim to the base, since dropping an optional parameter the base declares is a realclassmethod-override violation under mypy.pcapkit/const/ftp/command.py(CommandType,ConformanceRequirement) andpcapkit/protocols/internet/{esp,mh}.pyare untouched, still held by #913/#904 respectively.