Skip to content

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

Closed

Description

@JarryShaw

#877's phase 2 is half done. #921 re-parented 17 of the 24 non-registry enumerations onto EnumLookup; seven are still outside it, and #877 is closed, so nothing tracks them.

Measured on 4f3d43df7 by walking every importable pcapkit.* module (vendor templates excluded) and filtering on issubclass(cls, EnumLookup):

pcapkit.const.ftp.command.CommandType
pcapkit.const.ftp.command.ConformanceRequirement
pcapkit.protocols.internet.esp.ESPStatus
pcapkit.protocols.internet.mh.FastBindingAcknowledgmentStatus
pcapkit.protocols.internet.mh.IPv6AddressPrefixCode
pcapkit.protocols.internet.mh.LMAAddressCode
pcapkit.protocols.internet.mh.LocalizedRoutingStatus

Why these seven and not the other 17. They were deliberately deferred, not overlooked. At the time #921 was written, const/ftp/command.py was held by #913 and esp.py / mh.py by #904 — so widening the in-flight worker's scope would have collided. All three blockers have since merged (1f433..., b3551cb63), so the contention is gone.

Scope

Re-parent each from (EnumBase,) to (EnumLookup, EnumBase), the same change #921 made for the other 17. #921's own PR is the pattern to follow, including its test file tests/corekit/test_enum_lookup_reparent_877_unit.py.

Two things #921 learned that apply here:

  • EnumLookup.get is a @classmethod. Any existing get override that is a @staticmethod cannot call super().get(...) — it raises RuntimeError: super(): no arguments. Check each of the seven for an override before assuming a bare re-parent suffices.
  • Member-table sizes must not change. Verify (len(__members__), len(list(cls))) before and after for each, since a re-parent that silently mints a member is the defect this programme exists to prevent.

Note the exception contract has moved since #921: EnumLookup.get now raises EnumKeyError / EnumValueError from pcapkit.utilities.exceptions (#923, merged as 4f3d43df7), so a name miss is KeyError-derived and raised quietly. mh.py's two except KeyError: raise EnumKeyError(...) conversions already reflect that and should be left alone.

Not blocked. No open PR touches these three files — #657 is docs-only and merges last.

Activity

  1. added
    enhancementIssues requesting a new capability (set by the feature request template)
    refactorRestructuring for its own sake — neither a fix nor a new capability (refactor: prefix)
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Sep 29, 2026
  2. JarryShaw commented on Sep 29, 2026

    @JarryShaw
    OwnerAuthor

    Correcting my own brief in this issue's body. The "Why these seven and not the other 17" paragraph says esp.py / mh.py were "held by #904". That is wrong, and #932's worker traced it back here after I flagged the same error in its conventions.rst prose.

    Measured: #904 never touched either file — its file list is pcapkit/protocols/internet/ipv6.py, the ipv6_generic_ext set, and tests/protocols/internet/test_mh_unit.py. The PR that genuinely held both esp.py and mh.py is #924 (issue #917, refactor(ipv6): rename IPv6_GenericExt to IPv6_Ext), merged 17:13:44Z as 93cf940b3.

    The #913 half is correct — it did hold pcapkit/const/ftp/command.py and pcapkit/vendor/ftp/command.py, merged 13:54:26Z as 1f4337e12.

    The deferral itself was still the right call, so the conclusion does not move — only the attribution. Leaving the body as written and recording the correction here rather than silently editing it, since #921's description carries the same error and cannot be corrected the same way.

  3. removed
    wipWork in flight - a covering PR is open or an agent is actively on it
    on Sep 30, 2026
  4. added this to the 1.5 milestone on Oct 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementIssues requesting a new capability (set by the feature request template)refactorRestructuring for its own sake — neither a fix nor a new capability (refactor: prefix)

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions