@@ -55,7 +55,7 @@ class TransportProtocol(EnumLookup, IntEnum):
5555 # instead of being split. With no decoding left to protect, the owner's own
5656 # further ruling on GitHub issue #860 retired the power-of-two spacing
5757 # itself too: that spacing existed mainly for code that composed values like
58- # ``tcp | udp``, which the new logic no longer accepts , so sequential
58+ # ``tcp | udp``, which the whole-value lookup does not accept , so sequential
5959 # ``auto()`` values are the expected behaviour. :meth:`AppType._dispatch`
6060 # never decodes an ``int`` -- composed by hand with ``|`` or passed bare --
6161 # into anything narrower than the whole value it already is, on either
@@ -68,8 +68,8 @@ class TransportProtocol(EnumLookup, IntEnum):
6868 # ``sctp``'s value -- resolves as ``dccp``'s, silently, with no
6969 # exception, since a real member sits at ``4`` either way. A caller holding
7070 # an integer under the old spacing (composed or not) can therefore land on a
71- # different real transport's registry after this change , not merely be
72- # refused where it previously resolved.
71+ # different real transport's registry under the sequential numbering , not
72+ # merely be refused where it previously resolved.
7373
7474 #: No transport protocol. ``TransportProtocol(0) is undefined`` and
7575 #: ``bool(undefined)`` is ``False``; it is the ``proto`` sentinel default
@@ -108,14 +108,12 @@ def get(cls, key: 'int | str', default: 'Any' = NO_DEFAULT) -> 'TransportProtoco
108108 ``Enum`` would raise in the circumstances, :exc:`ValueError` or
109109 :exc:`KeyError` as the case may be, and is to come from
110110 :mod:`pcapkit.utilities.exceptions` rather than being a builtin. A
111- stdlib ``E['nosuch']`` raises :exc:`KeyError`, and :issue:`923`'s census of the
112- 127 concrete :class:`~pcapkit.corekit.enum.EnumLookup` subclasses --
113- taken before the phase-2 re-parenting moved this class, so it is not
114- among them -- found 119 already answering a name miss that way against 5
115- answering with :exc:`ValueError`. Those 5 are :class:`AppType` and its
116- four transport registries, and they land there only because their own
117- ``get()`` takes an :class:`int` port and never accepts a name at all,
118- rather than from any name-miss policy. So there was no policy here to
111+ stdlib ``E['nosuch']`` raises :exc:`KeyError`, and :issue:`923`'s census
112+ found :class:`~pcapkit.corekit.enum.EnumLookup` subclasses answering a
113+ name miss that way. The exceptions were :class:`AppType` and its
114+ per-transport registries, and they answered with :exc:`ValueError` only
115+ because their own ``get()`` takes an :class:`int` port and never accepts
116+ a name at all, rather than from any name-miss policy. So there was no policy here to
119117 preserve, and a name miss reaches the caller as
120118 :exc:`~pcapkit.utilities.exceptions.EnumKeyError` from the base. The
121119 maintainer's ruling given in review of the work for :issue:`808`, that
@@ -127,25 +125,23 @@ def get(cls, key: 'int | str', default: 'Any' = NO_DEFAULT) -> 'TransportProtoco
127125 (:meth:`~pcapkit.corekit.enum.EnumLookup.get`), so this override
128126 moves from :class:`staticmethod` to :class:`classmethod` to
129127 delegate at all -- the same move GitHub issue :issue:`908` made for
130- :meth:`~pcapkit.const.http.method.Method.get`. Grepped every call
131- site in this tree for GitHub issue :issue:`877`: all call this method by
132- name, none take it as a bare callable or introspect ``__func__``,
133- so the switch is not caller-visible.
128+ :meth:`~pcapkit.const.http.method.Method.get`. A caller invoking it by
129+ name sees no difference between the two; only code taking it as a bare
130+ callable or introspecting ``__func__`` could tell them apart.
134131
135- ``default`` did not exist on this override before this change --
136- the original had no such parameter at all, which is a genuine LSP
137- violation once this class' ``get`` is a :class:`classmethod`
138- override of one that has it: a caller holding a
139- :class:`~pcapkit.corekit.enum.EnumLookup`-typed reference could pass
140- ``default=`` and, before this, would have hit a
141- :exc:`TypeError` at this subclass. Forwarded verbatim to
132+ ``default`` is accepted here because the original override had no
133+ such parameter at all, which is a genuine LSP violation once this
134+ class' ``get`` is a :class:`classmethod` override of one that has
135+ it: a caller holding a :class:`~pcapkit.corekit.enum.EnumLookup`-typed
136+ reference could pass ``default=`` and hit a :exc:`TypeError` at this
137+ subclass. Forwarded verbatim to
142138 :meth:`~pcapkit.corekit.enum.EnumLookup.get` rather than
143139 reimplemented, so it behaves exactly as the base's own ``default``
144140 does: a fallback to an *already-registered* value, resolved through
145141 ``_value2member_map_`` and never through the constructor, so
146- passing one still cannot mint. Every call site in this tree omits
147- it , so this is purely an added, backward-compatible capability, not
148- a change to anything this tree exercises today .
142+ passing one still cannot mint. A call that omits it resolves exactly
143+ as one made without the parameter did , so it is purely an added,
144+ backward-compatible capability .
149145
150146 Args:
151147 key: Key to get enum item.
@@ -184,17 +180,17 @@ def get(cls, key: 'int | str', default: 'Any' = NO_DEFAULT) -> 'TransportProtoco
184180 #
185181 # NOTE: the delegation below is exception-compatible for the keys this
186182 # signature admits -- an unrecognised :class:`int` still reaches the
187- # caller as a :exc:`ValueError`, now the base's own
183+ # caller as a :exc:`ValueError`, the base's own
188184 # :exc:`~pcapkit.utilities.exceptions.EnumValueError` since GitHub issue
189185 # #923 rather than ``aenum``'s bare one. It is not compatible for
190186 # keys outside it: ``None``, a :class:`float` and an unhashable key
191- # used to raise :exc:`AttributeError` from the ``key.lower()`` this
192- # branch no longer reaches , and now raise :exc:`ValueError` (or, for a
187+ # raised :exc:`AttributeError` from ``key.lower()`` before the
188+ # delegation , and raise :exc:`ValueError` through it (or, for a
193189 # :class:`float`, resolve -- ``get(1.0)`` answers ``tcp``, since
194190 # ``cls(key)`` accepts whatever :class:`int` equality accepts). No
195- # caller in this tree can reach any of those: the only live call site
196- # passes ``proto.lower()``, always a :class:`str`. The new shape is
197- # what every other ``EnumLookup`` subclass already does.
191+ # caller inside :mod:`pcapkit` can reach any of those: the only live call
192+ # site passes ``proto.lower()``, always a :class:`str`. Delegating is
193+ # what every other ``EnumLookup`` subclass does.
198194 return super ().get (key , default )
199195
200196 # NOTE: ``_missing_`` used to range-check ``value`` and then defer to
@@ -2472,7 +2468,7 @@ def __repr__(self) -> 'str':
24722468 # the plain form GitHub issue #806 already fixed: it is appended only
24732469 # when :attr:`aliases` is non-empty, so every member that does not
24742470 # share its port with another service -- the vast majority -- renders
2475- # exactly as it did before this issue . Registering a new alias through
2471+ # in the plain form unchanged . Registering a new alias through
24762472 # :meth:`register_alias` changes what *every* member already on that
24772473 # port renders, immediately, since :attr:`aliases` is derived fresh on
24782474 # each call rather than fixed at construction.
@@ -2717,8 +2713,9 @@ def get_all(cls, key: 'int', *,
27172713
27182714 :meth:`get` answers with one member because that is what a port lookup
27192715 means everywhere else -- :func:`socket.getservbyport` returns a single
2720- name -- but IANA really did register all three services on TCP/80, and
2721- discarding two of them would be inventing a registry it does not have.
2716+ name -- but IANA really does register more than one service on some
2717+ ports, TCP/80 among them, and discarding all but one would be inventing
2718+ a registry it does not have.
27222719 This is how the rest are reached.
27232720
27242721 Args:
0 commit comments