Skip to content

refactor(const,protocols): reparent the last seven non-registry enums onto EnumLookup - #932

Merged
JarryShaw merged 1 commit into
mainfrom
refactor/930-reparent-last-seven-enums
Sep 30, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
refactor/930-reparent-last-seven-enums

Conversation

@JarryShaw

@JarryShaw JarryShaw commented Sep 29, 2026 •

Copy link
Copy Markdown
Owner

Please follow the guide below

What is the purpose of your pull request?

  • refactor — changes neither behaviour nor performance

Description of your pull request and other information

Closes #930. Finishes #877's phase 2 -- #921 re-parented 17 of the 24 non-registry enumerations onto EnumLookup and deliberately left the remaining seven alone because the files holding them were still being edited by other pull requests: pcapkit.const.ftp.command (CommandType, ConformanceRequirement) and its vendor template, both touched by #913; and pcapkit.protocols.internet.esp (ESPStatus) plus pcapkit.protocols.internet.mh (FastBindingAcknowledgmentStatus, IPv6AddressPrefixCode, LMAAddressCode, LocalizedRoutingStatus), both files touched by #924. Both have since merged. (An earlier draft of this description and of conventions.rst named #904 for the esp.py/mh.py half; verified against gh api repos/JarryShaw/PyPCAPKit/pulls/904/files, #904 never touches either file -- #924 does. Corrected in both places.)

Re-derived the census myself first (pkgutil.walk_packages over every importable pcapkit.* module, vendor templates excluded, filtering on issubclass(cls, EnumLookup)) and got exactly the same seven the issue names -- no extras, no omissions.

FastBindingAcknowledgmentStatus and IPv6AddressPrefixCode already had their own get, both still a staticmethod -- kept untouched per the issue's own brief, since neither calls super().get(...) (so the staticmethod-delegating-to-classmethod RuntimeError trap #921 hit never applies here) and #923 already converted their name-miss to the in-library EnumKeyError, exactly the shape the base now uses. Keeping the @staticmethod does trip mypy's [override] and pylint's arguments-differ against the base's classmethod signature; both are suppressed (# type: ignore[override] # pylint: disable=arguments-differ, matching existing precedent in pcapkit/vendor/reg/apptype/apptype.py) rather than resolved by widening the signature, since that would mean touching the kept logic. The other five (CommandType, ConformanceRequirement, ESPStatus, LocalizedRoutingStatus, LMAAddressCode) are pure re-parents with no get of their own to reconcile.

One new public-API surface is worth calling out on its own: get_all, inherited from EnumLookup for the first time on FastBindingAcknowledgmentStatus/IPv6AddressPrefixCode, calls their kept get internally, so a name miss reached through get_all now reaches whatever get itself does. I asked separately whether these two overrides should adopt the base's own quiet=True. The owner's first answer was no (settled on #933); four minutes later he corrected himself, verbatim: "Oh wait. I meant, they should follow house convention and not to be loud." So both overrides do now adopt quiet=True -- a real behaviour change, not merely new reachability: pre-fix, a name miss on either class logged once at CRITICAL and set sys.tracebacklimit = 0 process-wide; post-fix, it does neither, on get or on the newly-inherited get_all. Both overrides' docstrings and the renamed KeptOverrideQuietnessTests test class cite #933 for the converged, quiet answer.

Member-table sizes are unchanged for all seven (verified len(__members__) and len(list(cls)) before and after, plus a runtime battery of lookups that doesn't grow any of them).

pcapkit/vendor/ftp/command.py (the crawler template) is updated in lockstep with pcapkit/const/ftp/command.py, matching house rule that a generated registry's shape lives in the crawler.

Also brought docs/source/contributing/conventions.rst and its own tests/project/test_conventions_doc_claims.py in line, since #929 merged in the interim and both said seven remained outside the hierarchy. Phase 2 is now 24 of 24, zero enumerations outside EnumLookup -- both doc-claims tests still derive their figures from a runtime walk rather than a hardcoded number, so they keep pinning the fact rather than a snapshot of it. test_the_page_names_every_enumeration_outside_the_hierarchy is now vacuous (its loop has nothing left to iterate) and says so explicitly via skipTest rather than passing silently.

New test file tests/corekit/test_enum_lookup_reparent_930_unit.py pins: the base-tuple/MRO change and member-table sizes for all seven, that get resolves by name and by value, what a miss raises (KeyError-derived for a name, ValueError-derived for a value), that the two kept overrides are still staticmethod while the five pure re-parents inherit the base classmethod, that a battery of lookups mints nothing, the zero-outside census itself, and the get/get_all quietness described above. Measured against the three source files reverted to af2324522 (plain unittest, each subTest resolved back to its parent method via getattr(test, 'test_case', test) -- without that resolution a subTest-only failure is recorded against unittest.case._SubTest and its parent method misreads as passing): 22 of its 27 test methods fail or error; five hold. One is a scaffolding guard (ZeroRemainOutsideEnumLookupTests.test_the_walk_found_something_to_count). The other four hold because FastBindingAcknowledgmentStatus/IPv6AddressPrefixCode already had a working get before this change, so their name/value lookup and failed-lookup behaviour -- not their loudness, see below -- is unaffected by the re-parent (FailedLookupTests/GetByNameAndValueTests ×2 each). What does fail for both classes is their own ReparentedBasesTests method and both KeptOverrideQuietnessTests methods: the base-tuple change, get_all's existence, and the switch from loud to quiet are each real regardless of whether get's name/value resolution already worked. (This count moved twice during review. An earlier revision undercounted it as one hold out of 25/34; a cross-review caught that and it was re-measured to 21/27 with six holding. The #933 reversal above then flipped test_get_is_now_quiet_on_both_classes from holding to failing -- it used to pin loud, which already matched the reverted tree; it now pins quiet, which the reverted tree's genuinely-loud get fails -- landing on the 22/27 five-hold figure quoted here, which is also what the file's own module docstring now says.)

Three pre-existing tests made stale claims this change falsifies, fixed in the same commit: test_const_enum_get.py's EXPECTED_WITHOUT_AN_INTEGER_DEFAULT exclusion set (now empty, CommandType/ConformanceRequirement moved into the main sweep), test_const_ftp_featcode_case_903_unit.py's literal import-line assertion (now includes EnumLookup), and test_mh_unit.py's hasattr(enum_cls, 'get') assertion for LocalizedRoutingStatus/LMAAddressCode (now True, inherited from the base rather than absent).

Linters, re-measured against a freshly-extracted baseline of the four touched source files from af2324522 rather than summarised: mypy reports the same 17 pre-existing errors either side (none in the [override]/arguments-differ category the two suppressions target); pylint reports 391 messages either side, identical message-for-message bar a one-line shift from my own added import (confirmed by diffing the sorted message lists); isort -l100 -ppcapkit is clean (exit 0, no diff) on all four files, matching tests/project/test_isort_clean.py.

Tests: every batch I ran individually is green -- tests/const/test_const_enum_get.py, test_const_enum_no_mint.py, test_const_enum_builtin_parity.py, test_const_enum_lookup.py, test_const_ftp_featcode_case_903_unit.py (144 tests); tests/dumpkit/test_nameless_enum_rendering_unit.py plus tests/protocols/internet/test_esp_unit.py/test_mh_unit.py (81 tests); tests/corekit/test_sentinel_exports_unit.py, test_enum_lookup_reparent_877_unit.py, the new test_enum_lookup_reparent_930_unit.py, tests/project/test_conventions_doc_claims.py, and test_isort_clean.py (98 tests, 1 skipped as above). I previously reported that combining all thirteen of those files into one python -m unittest invocation threw 37 failures, and attributed it to a "pre-existing sys.modules-purge isolation artifact" without having reproduced that mechanism -- a cross-review couldn't reproduce it and called that out correctly. Re-measured: it does reproduce, deterministically, under plain python -m unittest with this exact 13-file list. That is pre-existing on clean main under bare unittest, measured -- not merely a pytest-vs-unittest difference, which is what I said the first time and which undersold it: the 24 tests/corekit/test_*.py files common to both trees, run under bare unittest on an unmodified af2324522 checkout (git worktree add --detach to a scratch path, removed afterward), throw their own cross-file failures independent of anything in this PR -- ran=370 failure_entries=5 error_entries=0 distinct_bad=3, all three inside test_sentinel_exports_unit.py (NoValueIsTheDocumentedFieldDefaultTests ×2, SentinelExportTests.test_star_import_hands_back_the_canonical_object) -- which I reproduced independently rather than took on faith. The identical 13 files on this branch under pytest, which is what make test actually invokes, are clean: 322 passed, 1 skipped, 0 failed, matching a cross-review's own result. So: pre-existing on main under bare unittest; clean under the runner this project's own tooling uses. I withdraw both the "isolation artifact" and the "runner-specific" framings as incomplete, and replace them with this directly-reproduced pair of findings.

@JarryShaw JarryShaw added refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix) const Regenerated IANA or vendor constant tables; members keep their numeric values test Pull requests that add or correct tests (test: subject prefix) docs Pull requests that change documentation only (docs: subject prefix) review: pending No verdict for the current head - never reviewed, or the head moved since the last one labels Sep 29, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Two PR cross-references in the conventions.rst prose are wrong, measured against the API rather than inferred:

The version #929 merged named no PR numbers and was not wrong; the numbers were added here. Being fixed on the same commit — either with the accurate attribution or by dropping the numbers.

Independently verified on my side, against head 36f34bc2c (parent af2324522 = current main, one commit):

  • the enum census — 144 EnumLookup subclasses, 0 outside the hierarchy, by a runtime pkgutil.walk_packages over non-vendor pcapkit.*, so "Zero enumerations remain outside" is true;
  • all four conventions.rst anchors still present and in order, which tests/corekit/test_sentinel_exports_unit.py slices by literal string;
  • the surviving "seven" mentions on the page are historical, not stale claims.

Opus cross-review in flight (author was Sonnet). CI green so far. Not ready to hand over.

@JarryShaw

Copy link
Copy Markdown
Owner Author

NEEDS CHANGES at f32fff038 — Opus cross-review (author was Sonnet), one blocking item, re-derived by me before relaying.

Blocking: tests/corekit/test_enum_lookup_reparent_930_unit.py:62-68 says only one test holds against the pre-fix tree. Five do. My own run — three source files reverted to af2324522, plain unittest, _SubTest resolved back to its parent case:

ran=25 failure_entries=8 error_entries=20
DISTINCT methods total=25 failing=20 holding=5

The four extras are GetByNameAndValueTests and FailedLookupTests on FastBindingAcknowledgmentStatus and IPv6AddressPrefixCode — they hold because those two already had their own get, which is this PR's own central point. The PR body repeats the error ("25 of 25 test methods bar one scaffolding guard"); its "28 of 34 assertions" is correct.

A new loud path, verified independently. get_all does not exist on FastBindingAcknowledgmentStatus pre-fix and does post-fix. On a miss it reaches the kept @staticmethod get, which raises EnumKeyError without quiet=True, unlike the base at pcapkit/corekit/enum.py:412:

HEAD    has get_all=True  raised=EnumKeyError  tracebacklimit '<unset>' -> 0
PRE-FIX has get_all=False raised=-             tracebacklimit '<unset>' -> '<unset>'

sys.tracebacklimit = 0 process-wide is the #362 hazard, now reachable through public API where it was not before. Being pinned with a test and documented, not changed — whether those two overrides should adopt the base's quiet=True is a contract question under the #923 ruling, which I am raising separately rather than deciding in a refactor.

Refuted, and it was the author's: the "37 failures in a combined run, a pre-existing isolation artifact" claim does not reproduce — 296 passed / 0 failed on base, 321 / 0 on head, the +25 being exactly the new file. Nothing to alibi, and nothing this PR caused.

Confirmed on the other claims: member counts identical for all seven (the CommandType 4/3 gap is aenum omitting the zero-valued IntFlag pseudo-member, not an alias — my own earlier framing was wrong); behaviour diff base↔head additive only; test_mh_unit.py:1637 strengthens rather than weakens; vendor template in lockstep; the corekit/enum.py docstring edit in scope; the 24 denominator legitimate (17 top-level + 7 nested httpv2 *.Flags). Anchor extension-header-subclassing at 759, both doc regexes match non-vacuously.

Still unverified by anyone: mypy / pylint / isort output, coverage delta, and whether the page renders without broken cross-references. Author asked for the real linter output.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment and removed review: pending No verdict for the current head - never reviewed, or the head moved since the last one labels Sep 29, 2026
@JarryShaw
JarryShaw force-pushed the refactor/930-reparent-last-seven-enums branch from f32fff0 to df8568a Compare September 29, 2026 21:38
… onto EnumLookup (#930)

Finishes #877's phase 2, which #921 left seven classes out of because their
files were held by #913/#904 at the time: CommandType and
ConformanceRequirement (const/ftp/command.py), ESPStatus
(protocols/internet/esp.py), and FastBindingAcknowledgmentStatus,
IPv6AddressPrefixCode, LMAAddressCode and LocalizedRoutingStatus
(protocols/internet/mh.py). Both blockers have since merged. Each now mixes
in EnumLookup ahead of its enum base; member-table sizes are unchanged.

FastBindingAcknowledgmentStatus and IPv6AddressPrefixCode kept their own
get, still a staticmethod that never calls super() -- left untouched, since
#923's EnumKeyError name-miss conversion already matches the base's shape.
mypy's [override] and pylint's arguments-differ against the kept decorator
are suppressed rather than resolved by widening it. The other five are
pure re-parents.

Brought conventions.rst and its own doc-claims test in line with #929,
which merged in the interim: phase 2 is now 24 of 24, zero enumerations
outside the hierarchy. Added test_enum_lookup_reparent_930_unit.py pinning
the re-parenting, the kept overrides, no growth, and the zero-outside
census; fixed three tests whose claims this change made stale
(test_const_enum_get, test_const_ftp_featcode_case_903_unit, test_mh_unit).

Build: mypy/pylint/isort clean against baseline; affected test files pass.
@JarryShaw
JarryShaw force-pushed the refactor/930-reparent-last-seven-enums branch from df8568a to 0a76861 Compare September 29, 2026 21:55
@JarryShaw

Copy link
Copy Markdown
Owner Author

Sphinx render verified — nothing this PR wrote is broken. Independent Opus check, explicit -n nitpicky build of both trees, plus a read of the rendered HTML rather than trusting the exit code (make html passes no -W and no nitpicky, so an unresolved role renders as plain text and CI stays green).

docs/source/contributing/conventions.rst carries 16 unresolved references, all 16 pre-existing on af2324522, zero introduced here. The two builds' warning sets are byte-identical — only in PR: [], only in BASE: [] — and every failing role text has the same count on both sides.

Everything #932's own prose cites resolves to a real <a href>: :class:~pcapkit.corekit.enum.EnumLookup (both occurrences), `:mod:`pcapkit.const.ftp.command, :mod:pcapkit.protocols.internet.esp, `:mod:`pcapkit.protocols.internet.mh, :mod:enum`` to docs.python.org, and all five GitHub links (#877, #913, #921, #924, #930). All four section anchors render with their id, and the one `:ref:` to `extension-header-subclassing` is a working internal link.

One line inside the rewritten .. note:: does fail — :mod:aenum`` at :388 — but it is present verbatim in the base's note too, so it is inherited, not introduced.

The 16 are a real docs defect on main and I have filed them separately rather than widening this PR.

Measured at df8568af0; the branch was force-pushed to 0a768610d mid-check, but conventions.rst is byte-identical between the two (diff -q clean), so the finding carries. 357 MB of build output and the scratch worktree cleaned up.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment labels Sep 29, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

GOOD TO GO at 0a768610d — Opus cross-review (author was Sonnet), every claim re-derived on both trees with pcapkit.__file__ asserted under each root.

The #933 reversal is correct and complete. Measured, head vs af2324522:

  • quiet works through all four entry points. get and get_all on both classes → EnumKeyError, sys.tracebacklimit <unset>→<unset>, 0 log records. On baseline, get set tracebacklimit to 0 and logged 1 CRITICAL, and get_all did not exist at all. EnumKeyError still subclasses both KeyError and BaseError, so a caller catching either is unaffected.
  • The rewritten test genuinely fails pre-fix. Reverting only the three source files: 27 total, 22 fail, 5 hold — up from 21/6, because test_get_is_now_quiet_on_both_classes moved from holding to failing. Both KeptOverrideQuietnessTests methods fail without the fix; 27/27 pass on head. The module docstring's own figure at :81 matches and names the same five.
  • No stale prose survives. Nothing anywhere still claims the overrides are loud; mh.py:653/:790 now say get used to be loud until refactor(const,protocols): reparent the last seven non-registry enums onto EnumLookup #930 converged it onto house convention.
  • Coverage does not drop: const/ftp/command.py 80→81%, internet/mh.py 93→93%, internet/esp.py 19→19%.
  • Both lint suppressions are load-bearing, not cosmetic: stripping them yields real [override] errors at mh.py:645 and :782, and --warn-unused-ignores reports neither as unused.

Two corrections to my own earlier report of the author's claims. The "mypy 17 errors" and "pylint 391 messages" figures were wrong — actual mypy is 321 errors / 38 files, and pylint repo-wide moves 6065 → 6077 (+12), all R0401 cyclic-import from the new pcapkit.corekit.enum edge in esp.py:177 and mh.py:80. What actually matters held: identical between trees for mypy, identical per changed file for pylint, score and exit code unchanged, isort exit 0 on all four legs.

One gap this surfaced is filed as #935 rather than fixed here — the two kept overrides advertise the base's get(key, default) and reject it with TypeError.

Unpublished and awaiting you. CI has one leg still running; I am not calling it merge-ready until that completes.

@JarryShaw

Copy link
Copy Markdown
Owner Author

I see one still using enum.IntEnum, we should use the pcapkit.corekit.compat.IntEnum instead.

@JarryShaw

Copy link
Copy Markdown
Owner Author

Ruling recorded, verbatim:

I see one still using enum.IntEnum, we should use the pcapkit.corekit.compat.IntEnum instead.

The finding is right. ESPStatus at pcapkit/protocols/internet/esp.py:458 is class ESPStatus(EnumLookup, enum.IntEnum) — the only one of the seven on stdlib enum. The other six are all aenum: CommandType (IntFlag), ConformanceRequirement, FastBindingAcknowledgmentStatus, IPv6AddressPrefixCode, LocalizedRoutingStatus, LMAAddressCode.

It is pre-existing, not introduced here. On main it is already class ESPStatus(enum.IntEnum) at af2324522:esp.py:457; this PR only put EnumLookup in front. Lining all seven up side by side is what made it visible.

Two things block me from just doing it, so I would rather ask than guess.

First, pcapkit/corekit/compat.py does not exist — the only compat module in the tree is pcapkit/utilities/compat.py, and it exports StrEnum and auto but no IntEnum. So this needs a shim created, not repointed.

Second, and more interesting: unlike StrEnum, IntEnum has no version gap to bridge — stdlib has had it since 3.4, so utilities/compat.py's sys.version_info < (3, 11) pattern has nothing to guard against here. A compat IntEnum would therefore be about library uniformity (aenum vs stdlib as the project's canonical IntEnum), not compatibility. That matters because utilities/compat.py:143-152 records, measured, that the two libraries are not interchangeable — each metaclass only recognises its own auto sentinel — so "canonical IntEnum" is a real decision with consequences for extend_enum and every class body.

So: do you want (a) a new IntEnum in pcapkit/utilities/compat.py re-exporting aenum's, matching the six others, with ESPStatus repointed at it; (b) the same but stdlib's; or (c) ESPStatus simply switched to from aenum import IntEnum like its siblings, with no new shim? I lean (a) — it gives one canonical import point and matches the six, and corekit versus utilities is then just where you want it to live.

review: good-to-go removed, review: needs-changes applied — this PR is no longer ready to merge.

@JarryShaw JarryShaw added review: needs-changes Cross-review at the current head says changes are required; see the verdict comment needs: decision Waiting on the maintainer to decide — not blocked by other work and removed review: good-to-go Cross-review at the current head says ready; CI state is separate labels Sep 30, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

go with (a) but i thought we already had that in other enumerations? how are we using IntEnum in other enumerations? from compat or directly from enum? if the former, then yes, definitely (a); but if the latter, we keep that convention.

@JarryShaw

Copy link
Copy Markdown
Owner Author

Ruling recorded, verbatim:

go with (a) but i thought we already had that in other enumerations? how are we using IntEnum in other enumerations? from compat or directly from enum? if the former, then yes, definitely (a); but if the latter, we keep that convention.

Measured, and your conditional resolves to "the latter" — so by your own rule we keep the convention and change nothing. Census across pcapkit/:

  • Zero files import IntEnum or IntFlag from any compat module. There is no compat IntEnum to import; the "former" branch is empty.
  • 157 import sites resolve to aenum, 26 to enum — but 25 of those 26 are if TYPE_CHECKING: aliases of the form from enum import IntEnum as StdlibEnum paired with from aenum import IntEnum as AenumEnum. That is a type-union annotation pattern, not a base-class choice. The 26th is inside pcapkit/utilities/compat.py:206 itself.

So ESPStatus is not the odd one out. Classes actually based on stdlib enum.IntEnum:

pcapkit/corekit/infoclass.py:35        class FinalisedState(EnumLookup, enum.IntEnum)
pcapkit/protocols/misc/pcapng.py:249  class PacketDirection(EnumLookup, enum.IntEnum)
pcapkit/protocols/misc/pcapng.py:267  class PacketReception(EnumLookup, enum.IntEnum)
pcapkit/protocols/internet/esp.py:457 class ESPStatus(enum.IntEnum)          <- pre-existing on main

Three pre-existing classes already pair EnumLookup with stdlib enum.IntEnum, exactly the shape #932 gives ESPStatus. None of the four uses extend_enum, which is what would force aenum.

The honest counter-evidence, so this is not cherry-picked: the four mh.py helpers use aenum via a module-level from aenum import IntEnum at mh.py:30, and they do not use extend_enum either — so among hand-written EnumLookup enums the split is genuinely mixed, 4 stdlib against 4 aenum, rather than one clean convention. Only the generated const/ tables have a forcing reason, and even there just 3 of 143 files call extend_enum.

So: no change to ESPStatus, per your rule. If you would rather unify the hand-written ones in one direction, that is a larger and separate piece of work — say the word and I will file it rather than fold it into #932.

needs: decision removed, review: good-to-go restored. #932 is BEHIND after #936 merged as ba83c4bb3, so it needs a rebase before it can go in; conventions.rst was untouched by that merge, so no conflict is expected.

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: needs-changes Cross-review at the current head says changes are required; see the verdict comment needs: decision Waiting on the maintainer to decide — not blocked by other work labels Sep 30, 2026
@JarryShaw
JarryShaw merged commit 3823758 into main Sep 30, 2026
63 checks passed
@JarryShaw
JarryShaw deleted the refactor/930-reparent-last-seven-enums branch September 30, 2026 00:19
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Sep 30, 2026
JarryShaw added a commit that referenced this pull request Sep 30, 2026
…efault

FastBindingAcknowledgmentStatus.get and IPv6AddressPrefixCode.get were
re-parented onto EnumLookup by #932, which made them advertise the
base's two-argument get(key, default) through inheritance while their
own @staticmethod overrides still only accepted one -- a default
argument raised TypeError instead of the base's own fallback.

- Widen both signatures to key, default=NO_DEFAULT and resolve default
  through _value2member_map_, matching the base's own contract exactly
  rather than through the constructor: that constructor's own miss
  path, _missing_, raises loud, so probing a candidate default through
  it would set sys.tracebacklimit process-wide even on a miss the
  method goes on to answer quietly (the #362 hazard).
- Remove both `# type: ignore[override] # pylint: disable=arguments-differ`
  suppressions the signature mismatch used to need; a narrow
  `# type: ignore[misc]` covers the four _value2member_map_ reads
  instead, since that attribute is generic over Self and mypy flags
  reading it through a bare class reference (no cls, staticmethod is
  kept) as ambiguous.
- Add coverage in test_mh_unit.py proving the TypeError is gone and
  default is honoured exactly as the pure re-parents honour it, and in
  test_enum_lookup_reparent_930_unit.py pinning that the widened
  default path still raises quietly.

Verified: mypy 321 errors/38 files and pylint 8.67/10 (exit 30) both
unchanged against 3823758, with the two former [override] errors
gone; all three target test modules pass individually.
JarryShaw added a commit that referenced this pull request Sep 30, 2026
…he base

FastBindingAcknowledgmentStatus.get and IPv6AddressPrefixCode.get were
re-parented onto EnumLookup by #932, which made them advertise the
base's two-argument get(key, default) through inheritance while their
own @staticmethod overrides still only accepted one. #935's first
ruling widened both signatures to accept default; asked next "why must
we have the two overrides tho? cant they directly fall back to the
base class's?", the owner's final ruling went further, verbatim: "I
prefer (2) directly" -- delete both overrides outright.

- Delete both get() methods. Neither minted an alias (__members__ and
  list(cls) already agreed at 6 and 4), so "Backport support for
  original codes" was just the int-or-name dual resolution the base
  already provides; all 20 call sites (all in tests) passed only an
  int or a str. Both classes now inherit get/get_all from the base,
  the same as the five other re-parents.
- Remove both `# type: ignore[override] # pylint: disable=arguments-differ`
  suppressions along with the methods -- absent now, not silenced.
  NO_DEFAULT and EnumKeyError drop out of the imports, unused once the
  methods that referenced them are gone.
- Behaviour change, deliberate: the overrides branched on
  isinstance(key, int) and misrouted every other type through the name
  path, so get(None)/get(1.5) answered with a quiet EnumKeyError here
  against a loud EnumValueError on the other five. Deleting them makes
  all seven answer alike for the first time.
- tests/corekit/test_enum_lookup_reparent_930_unit.py: drop the
  staticmethod pin in ReparentedBasesTests (nothing left to decorate);
  rename KeptOverrideQuietnessTests to InheritedQuietnessTests and
  PureReparentClassmethodTests to AllSevenInheritTheBareClassmethodTests,
  extended to all seven; add NonCanonicalKeyConvergenceTests pinning the
  get(None)/get(1.5) convergence.
- tests/protocols/internet/test_mh_unit.py: repoint the default-widening
  test into one proving default now works uniformly across all four of
  this module's EnumLookup classes through the single inherited method.

Verified: mypy 321 errors/38 files and pylint 8.67/10 (exit 30) both
unchanged against 3823758 (the two mh.py pylint findings that do
disappear are the two now-deleted f-string-eligible raises); the two
[override] errors are absent rather than suppressed. All three target
test modules pass individually; the new convergence and uniformity
tests both fail against 3823758 and pass here.
JarryShaw added a commit that referenced this pull request Sep 30, 2026
…he base

FastBindingAcknowledgmentStatus.get and IPv6AddressPrefixCode.get were
re-parented onto EnumLookup by #932, which made them advertise the
base's two-argument get(key, default) through inheritance while their
own @staticmethod overrides still only accepted one. #935's first
ruling widened both signatures to accept default; asked next "why must
we have the two overrides tho? cant they directly fall back to the
base class's?", the owner's final ruling went further, verbatim: "I
prefer (2) directly" -- delete both overrides outright.

- Delete both get() methods. Neither minted an alias (__members__ and
  list(cls) already agreed at 6 and 4), so "Backport support for
  original codes" was just the int-or-name dual resolution the base
  already provides; all 20 call sites (all in tests) passed only an
  int or a str. Both classes now inherit get/get_all from the base,
  the same as the five other re-parents.
- Remove both `# type: ignore[override] # pylint: disable=arguments-differ`
  suppressions along with the methods -- absent now, not silenced.
  NO_DEFAULT and EnumKeyError drop out of the imports, unused once the
  methods that referenced them are gone.
- Behaviour change, deliberate: the overrides branched on
  isinstance(key, int) and misrouted every other type through the name
  path, so get(None)/get(1.5) answered with a quiet EnumKeyError here
  against a loud EnumValueError on the other five. Deleting them makes
  all seven answer alike for the first time.
- tests/corekit/test_enum_lookup_reparent_930_unit.py: drop the
  staticmethod pin in ReparentedBasesTests (nothing left to decorate);
  rename KeptOverrideQuietnessTests to InheritedQuietnessTests and
  PureReparentClassmethodTests to AllSevenInheritTheBareClassmethodTests,
  extended to all seven; add NonCanonicalKeyConvergenceTests pinning the
  get(None)/get(1.5) convergence.
- tests/protocols/internet/test_mh_unit.py: repoint the default-widening
  test into one proving default now works uniformly across all four of
  this module's EnumLookup classes through the single inherited method.

Verified: mypy 321 errors/38 files and pylint 8.67/10 (exit 30) both
unchanged against 3823758 (the two mh.py pylint findings that do
disappear are the two now-deleted f-string-eligible raises); the two
[override] errors are absent rather than suppressed. All three target
test modules pass individually; the new convergence and uniformity
tests both fail against 3823758 and pass here.
JarryShaw added a commit that referenced this pull request Sep 30, 2026
…efault (#940)

FastBindingAcknowledgmentStatus.get and IPv6AddressPrefixCode.get were
re-parented onto EnumLookup by #932, which made them advertise the
base's two-argument get(key, default) through inheritance while their
own @staticmethod overrides still only accepted one. #935's first
ruling widened both signatures to accept default; asked next "why must
we have the two overrides tho? cant they directly fall back to the
base class's?", the owner's final ruling went further, verbatim: "I
prefer (2) directly" -- delete both overrides outright.

- Delete both get() methods. Neither minted an alias (__members__ and
  list(cls) already agreed at 6 and 4), so "Backport support for
  original codes" was just the int-or-name dual resolution the base
  already provides; all 20 call sites (all in tests) passed only an
  int or a str. Both classes now inherit get/get_all from the base,
  the same as the five other re-parents.
- Remove both `# type: ignore[override] # pylint: disable=arguments-differ`
  suppressions along with the methods -- absent now, not silenced.
  NO_DEFAULT and EnumKeyError drop out of the imports, unused once the
  methods that referenced them are gone.
- Behaviour change, deliberate: the overrides branched on
  isinstance(key, int) and misrouted every other type through the name
  path, so get(None)/get(1.5) answered with a quiet EnumKeyError here
  against a loud EnumValueError on the other five. Deleting them makes
  all seven answer alike for the first time.
- tests/corekit/test_enum_lookup_reparent_930_unit.py: drop the
  staticmethod pin in ReparentedBasesTests (nothing left to decorate);
  rename KeptOverrideQuietnessTests to InheritedQuietnessTests and
  PureReparentClassmethodTests to AllSevenInheritTheBareClassmethodTests,
  extended to all seven; add NonCanonicalKeyConvergenceTests pinning the
  get(None)/get(1.5) convergence.
- tests/protocols/internet/test_mh_unit.py: repoint the default-widening
  test into one proving default now works uniformly across all four of
  this module's EnumLookup classes through the single inherited method.

Verified: mypy 321 errors/38 files and pylint 8.67/10 (exit 30) both
unchanged against 3823758 (the two mh.py pylint findings that do
disappear are the two now-deleted f-string-eligible raises); the two
[override] errors are absent rather than suppressed. All three target
test modules pass individually; the new convergence and uniformity
tests both fail against 3823758 and pass here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

const Regenerated IANA or vendor constant tables; members keep their numeric values docs Pull requests that change documentation only (docs: subject prefix) refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix) test Pull requests that add or correct tests (test: subject prefix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(const,protocols): reparent the last seven non-registry enums onto EnumLookup

1 participant