Skip to content

Commit 55416da

Browse files
committed
docs(vendor): fix AppType template prose and six crawler Args mismatches (#2175)
Problem: the AppType template BASE (mirrored in the generated const module) carried change-relative and counted prose, and six crawler docstrings named the wrong parameter, held as KNOWN_DEFECTS. Fix: - Reword TransportProtocol's class comment, TransportProtocol.get (docstring and NOTE), AppType.__repr__'s NOTE and AppType.get_all in the template and, identically, in pcapkit/const/reg/apptype/apptype.py (regeneration needs IANA's live CSV): no counts, no timed wording. - mh/{binding_ack,binding_update,handover_ack,handover_initiate}_flag: context() documents 'data'; drop the useless arguments-differ / arguments-renamed pragmas on context() and process(). - pcapng/option_type.context() and vlan/priority_level.process(): document 'soup'. Test: tests/test_docstring_contract.py drops the six KNOWN_DEFECTS entries; test_documented_parameters_exist now guards all six.
1 parent 4c3d301 commit 55416da

9 files changed

Lines changed: 83 additions & 116 deletions

File tree

‎pcapkit/const/reg/apptype/apptype.py‎

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -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:

‎pcapkit/vendor/mh/binding_ack_flag.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class BindingACKFlag(Vendor):
9797
#: Link to registry.
9898
LINK = 'https://www.iana.org/assignments/mobility-parameters/mobility-parameters-12.csv'
9999

100-
def process(self, data: 'list[str]') -> 'list[str]': # type: ignore[override] # pylint: disable=arguments-differ,arguments-renamed
100+
def process(self, data: 'list[str]') -> 'list[str]': # type: ignore[override]
101101
"""Process CSV data.
102102
103103
Args:
@@ -145,11 +145,11 @@ def process(self, data: 'list[str]') -> 'list[str]': # type: ignore[override] #
145145
enum.append(f'{sufs}\n {pres}')
146146
return enum
147147

148-
def context(self, data: 'list[str]') -> 'str': # pylint: disable=arguments-differ,arguments-renamed
148+
def context(self, data: 'list[str]') -> 'str':
149149
"""Generate constant context.
150150
151151
Args:
152-
soup: Parsed HTML source.
152+
data: CSV data.
153153
154154
Returns:
155155
Constant context.

‎pcapkit/vendor/mh/binding_update_flag.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class BindingUpdateFlag(Vendor):
9696
#: Link to registry.
9797
LINK = 'https://www.iana.org/assignments/mobility-parameters/mobility-parameters-11.csv'
9898

99-
def process(self, data: 'list[str]') -> 'list[str]': # type: ignore[override] # pylint: disable=arguments-differ,arguments-renamed
99+
def process(self, data: 'list[str]') -> 'list[str]': # type: ignore[override]
100100
"""Process CSV data.
101101
102102
Args:
@@ -144,11 +144,11 @@ def process(self, data: 'list[str]') -> 'list[str]': # type: ignore[override] #
144144
enum.append(f'{sufs}\n {pres}')
145145
return enum
146146

147-
def context(self, data: 'list[str]') -> 'str': # pylint: disable=arguments-differ,arguments-renamed
147+
def context(self, data: 'list[str]') -> 'str':
148148
"""Generate constant context.
149149
150150
Args:
151-
soup: Parsed HTML source.
151+
data: CSV data.
152152
153153
Returns:
154154
Constant context.

‎pcapkit/vendor/mh/handover_ack_flag.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class HandoverACKFlag(Vendor):
9797
#: Link to registry.
9898
LINK = 'https://www.iana.org/assignments/mobility-parameters/handover-acknowledge-flags.csv'
9999

100-
def process(self, data: 'list[str]') -> 'list[str]': # type: ignore[override] # pylint: disable=arguments-differ,arguments-renamed
100+
def process(self, data: 'list[str]') -> 'list[str]': # type: ignore[override]
101101
"""Process CSV data.
102102
103103
Args:
@@ -140,11 +140,11 @@ def process(self, data: 'list[str]') -> 'list[str]': # type: ignore[override] #
140140
enum.append(f'{sufs}\n {pres}')
141141
return enum
142142

143-
def context(self, data: 'list[str]') -> 'str': # pylint: disable=arguments-differ,arguments-renamed
143+
def context(self, data: 'list[str]') -> 'str':
144144
"""Generate constant context.
145145
146146
Args:
147-
soup: Parsed HTML source.
147+
data: CSV data.
148148
149149
Returns:
150150
Constant context.

‎pcapkit/vendor/mh/handover_initiate_flag.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class HandoverInitiateFlag(Vendor):
9797
#: Link to registry.
9898
LINK = 'https://www.iana.org/assignments/mobility-parameters/handover-initiate-flags.csv'
9999

100-
def process(self, data: 'list[str]') -> 'list[str]': # type: ignore[override] # pylint: disable=arguments-differ,arguments-renamed
100+
def process(self, data: 'list[str]') -> 'list[str]': # type: ignore[override]
101101
"""Process CSV data.
102102
103103
Args:
@@ -140,11 +140,11 @@ def process(self, data: 'list[str]') -> 'list[str]': # type: ignore[override] #
140140
enum.append(f'{sufs}\n {pres}')
141141
return enum
142142

143-
def context(self, data: 'list[str]') -> 'str': # pylint: disable=arguments-differ,arguments-renamed
143+
def context(self, data: 'list[str]') -> 'str':
144144
"""Generate constant context.
145145
146146
Args:
147-
soup: Parsed HTML source.
147+
data: CSV data.
148148
149149
Returns:
150150
Constant context.

‎pcapkit/vendor/pcapng/option_type.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ def context(self, soup: 'dict[str, list[Tag]]') -> 'str': # type: ignore[overri
472472
"""Generate constant context.
473473
474474
Args:
475-
data: CSV data.
475+
soup: Registry data.
476476
477477
Returns:
478478
Constant context.

0 commit comments

Comments
 (0)