diff --git a/docs/source/pcapkit/const/mh.rst b/docs/source/pcapkit/const/mh.rst index 36b6e1cfd..aaeb0c788 100644 --- a/docs/source/pcapkit/const/mh.rst +++ b/docs/source/pcapkit/const/mh.rst @@ -93,7 +93,7 @@ enumerations include: * - :class:`MH_CGASec ` - CGA SEC [*]_ * - :class:`MH_BindingError ` - - Bingding Error Status Code [*]_ + - Binding Error Status Code [*]_ Access Technology Type Option Type Values ========================================= diff --git a/docs/source/pcapkit/const/ngap.rst b/docs/source/pcapkit/const/ngap.rst index d43df3f0a..f1361d54e 100644 --- a/docs/source/pcapkit/const/ngap.rst +++ b/docs/source/pcapkit/const/ngap.rst @@ -15,7 +15,7 @@ enumerations include: * - :class:`NGAP_ProtocolIE ` - NGAP Protocol IE Identifiers [*]_ -Both are automatically generated from |pycrate|_'s compiled NGAP +Each is automatically generated from |pycrate|_'s compiled NGAP specification rather than an IANA-style registry -- see :mod:`pcapkit.vendor.ngap.procedure_code`'s module docstring for why. diff --git a/docs/source/pcapkit/corekit/decorators.rst b/docs/source/pcapkit/corekit/decorators.rst index 41789d052..34d8be05a 100644 --- a/docs/source/pcapkit/corekit/decorators.rst +++ b/docs/source/pcapkit/corekit/decorators.rst @@ -13,7 +13,7 @@ decorators, including :func:`~pcapkit.corekit.decorators.seekset`, .. versionremoved:: 1.5.0 ``pcapkit.utilities.decorators``, now :mod:`pcapkit.corekit.decorators` - (:issue:`1735`). :mod:`pcapkit.utilities` does not export the three + (:issue:`1735`). :mod:`pcapkit.utilities` does not export these decorators either. .. autodecorator:: pcapkit.corekit.decorators.seekset @@ -24,7 +24,9 @@ decorators, including :func:`~pcapkit.corekit.decorators.seekset`, .. important:: - All three decorators above are designed for decorating *class methods*. + The decorators above are designed for decorating *methods*: an instance + method of a protocol for :func:`seekset` and :func:`beholder`, and a + classmethod of a schema for :func:`prepare`. For more information, please refer to the documentation of each decorator function. diff --git a/docs/source/pcapkit/corekit/enum.rst b/docs/source/pcapkit/corekit/enum.rst index 1a220ebb0..b0225443c 100644 --- a/docs/source/pcapkit/corekit/enum.rst +++ b/docs/source/pcapkit/corekit/enum.rst @@ -3,7 +3,7 @@ Enumeration Base .. module:: pcapkit.corekit.enum -:mod:`pcapkit.corekit.enum` contains the two bases every enumeration in this +:mod:`pcapkit.corekit.enum` contains the bases every enumeration in this library inherits from: :class:`EnumLookup`, the *lookup* half shared by open registries and closed sets alike, and its subclass :class:`EnumRegistry`, which adds the *mutating* half every registry under :mod:`pcapkit.const` inherits. diff --git a/docs/source/pcapkit/corekit/fields/misc.rst b/docs/source/pcapkit/corekit/fields/misc.rst index fc8d2f158..6c3d8bbca 100644 --- a/docs/source/pcapkit/corekit/fields/misc.rst +++ b/docs/source/pcapkit/corekit/fields/misc.rst @@ -25,6 +25,8 @@ Generic Data Fields :members: :show-inheritance: +.. autofunction:: pcapkit.corekit.fields.misc.nested_packet_context + .. autoclass:: pcapkit.corekit.fields.misc.PayloadField :members: :show-inheritance: @@ -43,7 +45,7 @@ Type Variables :type: pcapkit.protocols.schema.schema.Schema .. data:: _TP - :type: pcapkit.protocols.protocol.Protocol + :type: pcapkit.protocols.protocol.ProtocolBase .. data:: _TN :type: pcapkit.corekit.sentinels.NoValueType diff --git a/docs/source/pcapkit/corekit/fields/strings.rst b/docs/source/pcapkit/corekit/fields/strings.rst index 0db95fe72..2d96259cd 100644 --- a/docs/source/pcapkit/corekit/fields/strings.rst +++ b/docs/source/pcapkit/corekit/fields/strings.rst @@ -21,6 +21,10 @@ String-based Fields :members: :show-inheritance: +.. autoclass:: pcapkit.corekit.fields.strings.DecodedString + :members: + :show-inheritance: + .. autoclass:: pcapkit.corekit.fields.strings.BitField :members: :show-inheritance: @@ -36,4 +40,4 @@ Type Variables -------------- .. data:: _T - :type: str | bytes | python:dict[str, typing.Any] + :type: str | bytes | dict[str, typing.Any] diff --git a/docs/source/pcapkit/corekit/infoclass.rst b/docs/source/pcapkit/corekit/infoclass.rst index 3a8ba3cd6..68e197686 100644 --- a/docs/source/pcapkit/corekit/infoclass.rst +++ b/docs/source/pcapkit/corekit/infoclass.rst @@ -14,7 +14,9 @@ classes :class:`~pcapkit.corekit.infoclass.MultiInfo` and :members: :show-inheritance: - :param \*args: Arbitrary positional arguments. + :param dict\_: Source data, read as by :meth:`~pcapkit.corekit.infoclass.Info.from_dict`, + except that no value is rebuilt into the :class:`~pcapkit.corekit.infoclass.Info` + subclass its key's annotation names. :param \*\*kwargs: Arbitrary keyword arguments. .. autoattribute:: __additional__ @@ -39,6 +41,10 @@ Internal Definitions :no-members: :show-inheritance: +.. autoclass:: pcapkit.corekit.infoclass.FinalisedState + :members: + :show-inheritance: + .. autoclass:: pcapkit.corekit.infoclass._MultiInfo :no-members: :show-inheritance: diff --git a/docs/source/pcapkit/corekit/io.rst b/docs/source/pcapkit/corekit/io.rst index 7f8c0e26e..960511998 100644 --- a/docs/source/pcapkit/corekit/io.rst +++ b/docs/source/pcapkit/corekit/io.rst @@ -5,7 +5,7 @@ I/O Objects :mod:`pcapkit.corekit.io` contains :class:`~pcapkit.corekit.io.SeekableReader`, a seekable customisation of -:class:`io.BufferedReader`, and two stream proxies: +:class:`io.BufferedReader`, and the stream proxies: :class:`~pcapkit.corekit.io.PeekableStream`, which adds ``peek`` to a seekable stream, and :class:`~pcapkit.corekit.io.NamedStream`, which gives a stream a ``name``. diff --git a/docs/source/pcapkit/corekit/protochain.rst b/docs/source/pcapkit/corekit/protochain.rst index 49b96692c..ed082bac5 100644 --- a/docs/source/pcapkit/corekit/protochain.rst +++ b/docs/source/pcapkit/corekit/protochain.rst @@ -10,10 +10,6 @@ Protocol Chain :no-members: :show-inheritance: - :param proto: New protocol class on the top stack. - :param alias: New protocol alias on the top stack. - :param basis: Original protocol chain as base stacks. - .. autoproperty:: protocols .. autoproperty:: aliases .. autoproperty:: chain diff --git a/docs/source/pcapkit/corekit/sentinels.rst b/docs/source/pcapkit/corekit/sentinels.rst index fca1f74e1..029eff79e 100644 --- a/docs/source/pcapkit/corekit/sentinels.rst +++ b/docs/source/pcapkit/corekit/sentinels.rst @@ -8,7 +8,7 @@ singleton sentinel this package defines for itself: a value recognised only by identity (``value is SENTINEL``), so it cannot be confused with a value a caller might legitimately pass. -All four are defined here, and this is their only import path: the modules +They are all defined here, and this is their only import path: the modules that use them do not re-export them (:issue:`1744`). .. versionadded:: 1.5.0 @@ -31,7 +31,7 @@ that use them do not re-export them (:issue:`1744`). :class:`AbsentType` and :data:`ABSENT` are **private** -- never imported outside :mod:`pcapkit.protocols.protocol`, and named in no module's ``__all__``. For - SCREAMING_SNAKE consistency with the other three sentinels (see + SCREAMING_SNAKE consistency with the other sentinels (see :ref:`sentinel-convention`), neither carries the leading underscore that would hide it from Sphinx, so both are documented below and marked private. diff --git a/docs/source/pcapkit/vendor/mh.rst b/docs/source/pcapkit/vendor/mh.rst index 85e24bb61..c30da6506 100644 --- a/docs/source/pcapkit/vendor/mh.rst +++ b/docs/source/pcapkit/vendor/mh.rst @@ -93,7 +93,7 @@ vendor crawlers include: * - :class:`MH_CGASec ` - CGA SEC [*]_ * - :class:`MH_BindingError ` - - Bingding Error Status Code [*]_ + - Binding Error Status Code [*]_ Access Technology Type Option Type Values ========================================= diff --git a/docs/source/pcapkit/vendor/ngap.rst b/docs/source/pcapkit/vendor/ngap.rst index 2ec033c67..69d00c96c 100644 --- a/docs/source/pcapkit/vendor/ngap.rst +++ b/docs/source/pcapkit/vendor/ngap.rst @@ -15,7 +15,7 @@ vendor crawlers include: * - :class:`NGAP_ProtocolIE ` - NGAP Protocol IE Identifiers [*]_ -Both source the assignment from |pycrate|_'s already-installed, compiled NGAP +Each sources the assignment from |pycrate|_'s already-installed, compiled NGAP specification rather than fetching a network registry -- see the module docstring below for why. @@ -28,7 +28,7 @@ This module contains the vendor crawler for **NGAP Elementary Procedure Codes**, which is automatically generating :class:`pcapkit.const.ngap.procedure_code.ProcedureCode`. .. autoclass:: pcapkit.vendor.ngap.procedure_code.ProcedureCode - :members: FLAG, LINK + :members: FLAG :show-inheritance: NGAP Protocol IE Identifiers @@ -40,7 +40,7 @@ This module contains the vendor crawler for **NGAP Protocol IE Identifiers**, which is automatically generating :class:`pcapkit.const.ngap.protocol_ie.ProtocolIE`. .. autoclass:: pcapkit.vendor.ngap.protocol_ie.ProtocolIE - :members: FLAG, LINK + :members: FLAG :show-inheritance: .. rubric:: Footnotes diff --git a/docs/source/pcapkit/vendor/pcapng.rst b/docs/source/pcapkit/vendor/pcapng.rst index 0483f4d91..ff1af8ee0 100644 --- a/docs/source/pcapkit/vendor/pcapng.rst +++ b/docs/source/pcapkit/vendor/pcapng.rst @@ -29,14 +29,14 @@ vendor crawlers include: .. note:: - The three crawlers that scrape a registry table -- + The crawlers that scrape a registry table -- :class:`BlockType `, :class:`OptionType ` and :class:`RecordType ` -- all read revision ``-03`` of the draft, as each one's ``LINK`` below shows. Revision ``-02`` renders its registries as ASCII art inside ``
`` and carries no
-   registry ```` at all, so the ``table-1`` through ``table-10`` ids the
-   three crawlers select on exist only in ``-03``, where the registries are real
+   registry ``
`` at all, so the ``table-1`` through ``table-10`` ids + these crawlers select on exist only in ``-03``, where the registries are real tables. The footnotes below point at ``-03`` for the same reason. Block Types diff --git a/pcapkit/const/ftp/command.py b/pcapkit/const/ftp/command.py index b8ebc4037..9c3ac9e77 100644 --- a/pcapkit/const/ftp/command.py +++ b/pcapkit/const/ftp/command.py @@ -32,7 +32,7 @@ class FEATCode(EnumRegistry, StrEnum): .. note:: Declares every FEAT keyword the IANA registry's own ``FEAT code`` - column names -- the 5 group markers below plus the per-command + column names -- the group markers below plus the per-command keywords generated after them (data-driven, not hand-picked; see :meth:`~pcapkit.vendor.ftp.command.Command.process`) -- rather than minting the per-command ones at import time as an incidental side @@ -117,9 +117,9 @@ def get(cls, key: 'Any', default: 'Any' = NO_DEFAULT) -> 'FEATCode': this is done, implementations are recommended to use upper case letters when transmitting the feature response."* A caller feeding a ``FEAT`` response line is therefore holding upper case by - recommendation, while 5 of this registry's 15 codes are registered in - lower case -- measured on the IANA CSV: 10 distinct all-upper-case - keywords against ``base``, ``feat``, ``hist``, ``nat6`` and ``secu``, + recommendation, while some of this registry's codes are registered in + lower case -- measured on the IANA CSV: ``base``, ``feat``, ``hist``, + ``nat6`` and ``secu``, against all-upper-case keywords for the rest, with none mixed. Without this override ``get('BASE')`` raised :exc:`KeyError`, which is the defect GitHub issue :issue:`903`'s audit found. @@ -274,7 +274,7 @@ class Command(EnumRegistry, StrEnum): :meth:`register`, and ``get`` is not given enough information to create one. Concretely true here -- a bare wire command word carries no :attr:`feat`/:attr:`desc`/:attr:`type`/:attr:`conf`, so a minted member - had all four hollowed out to their defaults; :meth:`register` is the + had each of them hollowed out to its default; :meth:`register` is the path that can actually supply them. """ @@ -495,10 +495,10 @@ def _unregistered_member(cls, value: 'str', name: 'str') -> 'Command': entirely -- :meth:`~pcapkit.corekit.enum.EnumRegistry._unregistered_member` bypasses :meth:`__new__` (it calls - :class:`str`'s directly), so those four attributes would otherwise + :class:`str`'s directly), so those attributes would otherwise be absent and :meth:`__repr__` (which reads :attr:`desc`) would raise on the result. There is no more specific value to reconstruct - them from -- a bare wire command word carries none of the four, + them from -- a bare wire command word carries none of them, which is exactly the owner's reasoning for why ``get()``/ ``_missing_`` must not mint one: :meth:`register` is the path that can actually supply them. diff --git a/pcapkit/const/ftp/return_code.py b/pcapkit/const/ftp/return_code.py index 39c164bd5..163715a83 100644 --- a/pcapkit/const/ftp/return_code.py +++ b/pcapkit/const/ftp/return_code.py @@ -339,7 +339,7 @@ def _unregistered_member(cls, value: 'int', name: 'str') -> 'ReturnCode': same way :meth:`__new__` would, rather than leaving them unset -- :meth:`~pcapkit.corekit.enum.EnumRegistry._unregistered_member` bypasses :meth:`__new__` entirely (it calls :class:`int`'s directly), - so those three attributes would otherwise be missing from the result + so those attributes would otherwise be missing from the result and :meth:`__str__`/:meth:`__repr__` would raise on it. Args: diff --git a/pcapkit/const/http/method.py b/pcapkit/const/http/method.py index 821df8e99..c6ebd4a04 100644 --- a/pcapkit/const/http/method.py +++ b/pcapkit/const/http/method.py @@ -187,7 +187,7 @@ def _unregistered_member(cls, value: 'str', name: 'str') -> 'Method': :meth:`__new__` itself would, rather than missing entirely -- :meth:`~pcapkit.corekit.enum.EnumRegistry._unregistered_member` bypasses :meth:`__new__` (it calls :class:`str`'s directly), so - those two attributes would otherwise be absent. There is no more + those attributes would otherwise be absent. There is no more specific value to reconstruct them from -- a bare wire method verb carries neither, which is exactly the owner's reasoning for why ``get()``/``_missing_`` must not mint one: :meth:`register` is the @@ -329,8 +329,8 @@ def _missing_(cls, value: 'str') -> 'Method': :meth:`get`, which is case-**sensitive** per :rfc:`9110#section-9.1`. The split was ruled deliberate on GitHub issue :issue:`896`; GitHub issue :issue:`908` is the pointer between - the two, so a reader of this one file is not left with two - contradictory rationales and nothing tying them together. + the two, so the two rationales are not left contradicting each + other with nothing tying them together. """ if not isinstance(value, str): diff --git a/pcapkit/const/mh/__init__.py b/pcapkit/const/mh/__init__.py index 24f063f02..a89d91dd7 100644 --- a/pcapkit/const/mh/__init__.py +++ b/pcapkit/const/mh/__init__.py @@ -94,7 +94,7 @@ * - :class:`MH_CGASec ` - CGA SEC [*]_ * - :class:`MH_BindingError ` - - Bingding Error Status Code [*]_ + - Binding Error Status Code [*]_ .. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-1 .. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-2 diff --git a/pcapkit/const/ngap/__init__.py b/pcapkit/const/ngap/__init__.py index 2dc14d372..e228fa9d9 100644 --- a/pcapkit/const/ngap/__init__.py +++ b/pcapkit/const/ngap/__init__.py @@ -16,11 +16,12 @@ * - :class:`NGAP_ProtocolIE ` - NGAP Protocol IE Identifiers [*]_ -Both are automatically generated from +They are automatically generated by :mod:`pcapkit.vendor.ngap.procedure_code` and -:mod:`pcapkit.vendor.ngap.protocol_ie`, which source the assignment from +:mod:`pcapkit.vendor.ngap.protocol_ie` respectively, which source the assignment from |pycrate|_'s compiled NGAP specification rather than a network registry -- -see that module's docstring for why, and GitHub issue :issue:`880` for the ruling. +see :mod:`pcapkit.vendor.ngap.procedure_code`'s docstring for why, and GitHub +issue :issue:`880` for the ruling. .. [*] 3GPP TS 38.413 .. [*] 3GPP TS 38.413 diff --git a/pcapkit/const/reg/apptype/__init__.py b/pcapkit/const/reg/apptype/__init__.py index 8818cdf81..35919fa01 100644 --- a/pcapkit/const/reg/apptype/__init__.py +++ b/pcapkit/const/reg/apptype/__init__.py @@ -157,9 +157,9 @@ def __repr__(self) -> 'str': # NOTE: this is what makes ``AppType.get(port, proto=...)`` work on the base # class, which is where every caller in the library addresses it. It cannot live -# in ``apptype.py``: that module is imported *by* all four registries, so it -# cannot import them back. Here is the first point at which all four exist, or -# for the lazy two, where to import them from. +# in ``apptype.py``: that module is imported *by* every per-transport registry, +# so it cannot import them back. Here is the first point at which all of them +# exist, or, for the lazy ones, where to import them from. AppType.__registries__ = _Registries({ TransportProtocol.tcp: ModuleDescriptor(f'{__name__}.tcp', _LAZY['tcp']), TransportProtocol.udp: ModuleDescriptor(f'{__name__}.udp', _LAZY['udp']), @@ -187,7 +187,7 @@ class is bound here before it is returned. def __dir__() -> 'list[str]': - """The names an eager import of all four registries would list.""" + """The names an eager import of every per-transport registry would list.""" helpers = {'importlib', 'sys', 'TYPE_CHECKING', 'ModuleDescriptor', '_LAZY', '_Registries', '__getattr__', '__dir__'} return sorted({*globals(), *_LAZY, *_LAZY.values()} - helpers) diff --git a/pcapkit/const/reg/apptype/apptype.py b/pcapkit/const/reg/apptype/apptype.py index 8b0a96573..885445e76 100644 --- a/pcapkit/const/reg/apptype/apptype.py +++ b/pcapkit/const/reg/apptype/apptype.py @@ -242,8 +242,8 @@ class AppType(EnumRegistry, StrEnum): .. versionchanged:: 1.5.0 Split by transport protocol (:issue:`732`): :mod:`pcapkit.const.reg.apptype` - is a package, and every assignment is a member of one of the four - registries above rather than of this class. ``get()`` raises + is a package, and every assignment is a member of one of the per-transport + registries rather than of this class. ``get()`` raises :exc:`ValueError` for a port outside ``0``-``65535`` (:issue:`758`), and returns an unregistered member rather than minting one for a port the registry does not assign (:issue:`860`). @@ -2417,15 +2417,15 @@ class AppType(EnumRegistry, StrEnum): #: the last of them. #: #: Declared here as :obj:`None` and overridden in each subclass: a mutable - #: class attribute declared on this class would be *shared* by all four - #: subclasses, so they would collide with each other exactly as the ports of + #: class attribute declared on this class would be *shared* by every + #: subclass, so they would collide with each other exactly as the ports of #: one transport used to collide inside the old flat registry. __registry__: 'Optional[MultiDict[int, AppType]]' = None #: Registry class owning each transport protocol, i.e. what #: :meth:`get` delegates to when called on this class rather than on one of - #: them. Populated by :mod:`pcapkit.const.reg.apptype` once all four have - #: been imported, since this module cannot import its own subclasses. + #: them. Populated by :mod:`pcapkit.const.reg.apptype` once every one of + #: them has been imported, since this module cannot import its own subclasses. __registries__: 'dict[TransportProtocol, Type[AppType]]' = {} #: Canonical service per port, for the ports carrying more than one. The base @@ -2457,7 +2457,7 @@ def __new__(cls, value: 'int', name: 'str' = '', def aliases(self) -> 'tuple[AppType, ...]': """Other services sharing :attr:`port` in this member's own registry. - GitHub issue :issue:`807`. No storage of its own: IANA already keeps every + GitHub issue :issue:`807`. No storage of its own: the registry already keeps every colliding service as its own member of :data:`__registry__`, keyed on the shared port -- :meth:`get_all` already walks that same bucket to answer with the aliases after the canonical member, so this is exactly @@ -2504,7 +2504,7 @@ def __str__(self) -> 'str': # consequence worth stating plainly rather than leaving for a doctest # to trip over: ``str(member) == member.value`` already breaks at # class-creation time for every port that statically carries more - # than one service (94 such members as shipped); + # than one service; # :meth:`register_alias` merely adds to that set at runtime. base = f'{self.svc} [{self.port} - {self.proto.name}]' aliases = self.aliases @@ -2583,7 +2583,7 @@ def _dispatch(cls, key: 'int', proto: 'TransportProtocol | str | int') -> 'Type[ proto = TransportProtocol.get(proto.lower()) # NOTE: a direct dict lookup covers every genuine single transport -- - # one of the four real members, or a bare int equal to one of their + # one of the real members, or a bare int equal to one of their # values -- since ``__registries__`` keys compare by the same # int-valued hash/eq every member and bare int alike already use. The # cast is for mypy alone: ``dict.get`` accepts any hashable key at run @@ -2599,7 +2599,7 @@ def _dispatch(cls, key: 'int', proto: 'TransportProtocol | str | int') -> 'Type[ # member's value at the dict lookup above, and nothing below decodes # ``proto``'s bits looking for a partial answer either -- on either # numbering. A genuine member reaching this point is ``undefined`` -- - # the four real transports would already have resolved above, and + # a real transport would already have resolved above, and # :meth:`TransportProtocol.get` cannot mint anything else, per the # maintainer ruling given in review of the work for #808, against # extending TransportProtocol at all -- and a bare :class:`int` reaches @@ -2725,7 +2725,7 @@ def get_all(cls, key: 'int', *, Returns: The canonical member followed by its aliases, in registry row order. Never empty: a port with no assignment goes through :meth:`get`, so it - is minted rather than answered with an empty result. + is answered with an unregistered member rather than an empty result. Raises: ValueError: As :meth:`get`. @@ -2831,8 +2831,8 @@ def register(cls, port: 'int', name: 'str') -> 'AppType': # pylint: disable=arg Raises: ValueError: If called on a class that holds no members, i.e. on - :class:`AppType` itself, which is not one of the four - per-transport registries; if ``port`` already carries a + :class:`AppType` itself, which is not a + per-transport registry; if ``port`` already carries a member of this registry; if ``name`` sanitises to text that is not a valid Python identifier at all; or if the identifier it does sanitise to already names an unrelated member of this @@ -2885,7 +2885,7 @@ def register_alias(cls, port: 'int', name: 'str') -> 'AppType': # pylint: disab The Python attribute name is derived from ``name`` through :meth:`_sanitize_identifier`. It has to be ``name``, not ``port`` and - a counter: an alias whose own name does not resolve through + a counter: an alias whose own name resolves through subscription is most of the point of registering one, and ``TCP['www_http']`` resolving is exactly what lets a caller reach an alias the same way every statically declared member already is. @@ -2906,8 +2906,8 @@ def register_alias(cls, port: 'int', name: 'str') -> 'AppType': # pylint: disab Raises: ValueError: If called on a class that holds no members, i.e. on - :class:`AppType` itself, which is not one of the four - per-transport registries; if ``port`` carries no member of + :class:`AppType` itself, which is not a + per-transport registry; if ``port`` carries no member of this registry yet; if ``name`` already names one of the members already there; if ``name`` sanitises to text that is not a valid Python identifier at all -- empty, or leading with @@ -2926,9 +2926,9 @@ def register_alias(cls, port: 'int', name: 'str') -> 'AppType': # pylint: disab if any(member.svc == name for member in existing): raise ValueError(f'{name!r} is already registered on port {port} of {cls.__name__}') - # NOTE: the 58 members the generator mints via safe_name's own + # NOTE: the members the generator mints via safe_name's own # fallback -- ``{cls.__name__}_{residue}``, when the sanitised - # residue is not a valid identifier (28 TCP, 29 UDP, 1 SCTP, 0 DCCP) -- + # residue is not a valid identifier -- # are names this runtime path refuses rather than accepts: that # fallback is deliberately not reproduced in # :meth:`_sanitize_identifier`, which raises here instead (see Raises @@ -2965,7 +2965,7 @@ def _unregistered_member(cls, value: 'int', name: 'str', :meth:`~pcapkit.corekit.enum.EnumRegistry._unregistered_member` bypasses :meth:`__new__` entirely (it builds through ``cls._member_type_.__new__`` directly), so this - class's own three attributes would otherwise be missing and every + class's own attributes (``svc``, ``port``, ``proto``) would otherwise be missing and every method reading them (:meth:`__repr__`, :meth:`__str__`, :meth:`__int__`, the comparison operators, :attr:`aliases`) would raise on the result. Deliberately *not* added to :data:`__registry__` -- unlike diff --git a/pcapkit/const/reg/apptype/dccp.py b/pcapkit/const/reg/apptype/dccp.py index b875af185..fd3281396 100644 --- a/pcapkit/const/reg/apptype/dccp.py +++ b/pcapkit/const/reg/apptype/dccp.py @@ -45,7 +45,7 @@ class DCCP(AppType): __transport__: 'TransportProtocol' = TransportProtocol.dccp #: Members of this registry, keyed on port number. Declared per registry - #: rather than inherited, since one mapping shared by all four would put + #: rather than inherited, since one mapping shared by every registry would put #: every transport's ports in the same key space. __registry__: 'MultiDict[int, DCCP]' = MultiDict() diff --git a/pcapkit/const/reg/apptype/sctp.py b/pcapkit/const/reg/apptype/sctp.py index ec142cf57..34846a022 100644 --- a/pcapkit/const/reg/apptype/sctp.py +++ b/pcapkit/const/reg/apptype/sctp.py @@ -49,7 +49,7 @@ class SCTP(AppType): __transport__: 'TransportProtocol' = TransportProtocol.sctp #: Members of this registry, keyed on port number. Declared per registry - #: rather than inherited, since one mapping shared by all four would put + #: rather than inherited, since one mapping shared by every registry would put #: every transport's ports in the same key space. __registry__: 'MultiDict[int, SCTP]' = MultiDict() diff --git a/pcapkit/const/reg/apptype/tcp.py b/pcapkit/const/reg/apptype/tcp.py index 89fbecf88..3548a87cd 100644 --- a/pcapkit/const/reg/apptype/tcp.py +++ b/pcapkit/const/reg/apptype/tcp.py @@ -902,7 +902,7 @@ class TCP(AppType): __transport__: 'TransportProtocol' = TransportProtocol.tcp #: Members of this registry, keyed on port number. Declared per registry - #: rather than inherited, since one mapping shared by all four would put + #: rather than inherited, since one mapping shared by every registry would put #: every transport's ports in the same key space. __registry__: 'MultiDict[int, TCP]' = MultiDict() diff --git a/pcapkit/const/reg/apptype/udp.py b/pcapkit/const/reg/apptype/udp.py index 43e45253e..f9af03e60 100644 --- a/pcapkit/const/reg/apptype/udp.py +++ b/pcapkit/const/reg/apptype/udp.py @@ -368,7 +368,7 @@ class UDP(AppType): __transport__: 'TransportProtocol' = TransportProtocol.udp #: Members of this registry, keyed on port number. Declared per registry - #: rather than inherited, since one mapping shared by all four would put + #: rather than inherited, since one mapping shared by every registry would put #: every transport's ports in the same key space. __registry__: 'MultiDict[int, UDP]' = MultiDict() diff --git a/pcapkit/corekit/decorators.py b/pcapkit/corekit/decorators.py index c8fc680f7..517ca0259 100644 --- a/pcapkit/corekit/decorators.py +++ b/pcapkit/corekit/decorators.py @@ -20,7 +20,7 @@ .. versionremoved:: 1.5.0 ``pcapkit.utilities.decorators``, now :mod:`pcapkit.corekit.decorators` - (:issue:`1735`). :mod:`pcapkit.utilities` does not export the three + (:issue:`1735`). :mod:`pcapkit.utilities` does not export these decorators either. """ @@ -58,7 +58,7 @@ def seekset(func: 'Callable[Concatenate[ProtocolBase, P], R_seekset]') -> 'Calla """Read file from start then set back to original. Important: - This decorator function is designed for decorating *class methods*. + This decorator function is designed for decorating *instance methods*. The decorator will keep the current offset of :attr:`self._file `, then call the decorated function. Afterwards, it will rewind the offset of @@ -101,7 +101,7 @@ def beholder( """Behold extraction procedure. Important: - This decorator function is designed for decorating *class methods*. + This decorator function is designed for decorating *instance methods*. This decorator calls the decorated function. Should any exception be raised, it logs the error and re-parses the current layer's payload as @@ -159,7 +159,7 @@ def behold(*args: 'P.args', **kwargs: 'P.kwargs') -> 'R_beholder': # NOTE: ``self._get_payload()`` rather than # ``self.__header__.get_payload()``, which it wraps. The two agree # for every protocol whose payload is a schema field, and differ for - # the two that override it: SCTP carries user data inside a DATA + # the protocols that override it: SCTP carries user data inside a DATA # chunk and PCAP-NG inside a block, so neither header schema has a # ``payload`` field at all. Going through the schema there raises # ProtocolUnbound('unknown field: payload') *from the recovery path*, @@ -226,12 +226,11 @@ def prepare(func: 'Callable[Concatenate[Type[R_prepare], bytes | IO[bytes], Opti packet: 'Optional[dict[str, Any]]') -> 'pcapkit.protocols.schema.schema.Schema' No further positional or keyword arguments are read from -- or - forwarded to -- the decorated function. :func:`prepare` is applied to - exactly one function in this tree, + forwarded to -- the decorated function. :func:`prepare` is applied only to :meth:`Schema.unpack `, - whose real signature has exactly these four parameters, and nothing + whose real signature has exactly these parameters, and nothing calls it with more. Rather than discard extras silently (:issue:`454`), - the wrapper raises :exc:`TypeError` for a fifth positional argument or + the wrapper raises :exc:`TypeError` for an extra positional argument or an unconsumed keyword, the same as an ordinary call with too many arguments would. @@ -254,9 +253,9 @@ def unpack(*args: 'P.args', **kwargs: 'P.kwargs') -> 'R_prepare': length = cast('Optional[int]', args[2] if len(args) > 2 else kwargs.pop('length', None)) packet = cast('Optional[dict[str, Any]]', args[3] if len(args) > 3 else kwargs.pop('packet', None)) - # NOTE: The decorated function's real signature is exactly the four + # NOTE: The decorated function's real signature is exactly the # parameters above -- see #454. Anything left over here is therefore - # unwanted rather than something to forward: a fifth positional + # unwanted rather than something to forward: an extra positional # argument, or a keyword that ``kwargs.pop`` above never touched # because ``length``/``packet`` arrived positionally instead. The # latter is also what catches ``length`` (or ``packet``) supplied diff --git a/pcapkit/corekit/enum.py b/pcapkit/corekit/enum.py index a11165f6f..db1a9c08c 100644 --- a/pcapkit/corekit/enum.py +++ b/pcapkit/corekit/enum.py @@ -4,7 +4,7 @@ .. module:: pcapkit.corekit.enum -:mod:`pcapkit.corekit.enum` contains the two bases every enumeration in this +:mod:`pcapkit.corekit.enum` contains the bases every enumeration in this library is meant to inherit from, split by whether the enumeration may *grow*: * :class:`EnumLookup` -- the bare **lookup** half: :meth:`~EnumLookup.get`, @@ -29,16 +29,16 @@ bad precedent. Following that through, a base holding both would leave :class:`EnumRegistry` with only ``register_aliases``, ``_extend`` and ``_unregistered_member`` -- too thin to -justify a second class, collapsing the two tiers into one. So all five mutating -methods stay put, and what the base carries instead is the other requirement +justify a second class, collapsing the two tiers into one. So every mutating +method stays put, and what the base carries instead is the other requirement from that thread: some range-validation logic that inheriting classes can hook into, which is :meth:`EnumLookup._validate_value`. Legality is every enumeration's concern; mutation is only the open registries'. -Supporting measurement, taken when :issue:`877` split the tiers: **0** of the -26 non-registry enumerations define ``register``, ``register_alias``, -``register_aliases`` or ``_unregistered_member``, and there are **0** -:class:`EnumRegistry` subclasses outside :mod:`pcapkit.const`. The mutating half +Supporting measurement, taken when :issue:`877` split the tiers: **none** of +the non-registry enumerations defines ``register``, ``register_alias``, +``register_aliases`` or ``_unregistered_member``, and **no** +:class:`EnumRegistry` subclass exists outside :mod:`pcapkit.const`. The mutating half therefore had no users to serve among the classes being re-parented. The registry tier's own shape is the earlier design settled in GitHub issue @@ -49,15 +49,16 @@ logic it needs, and ``AppType``'s subclasses override again where their contracts differ. -That is a three-tier hierarchy, of which this module is **tier one**: +That is a tiered hierarchy, of which this module is **tier one**: -1. :class:`EnumRegistry` -- the four methods, in the form that suits a registry - mapping one key to one member. Two are its own, ``register`` and - ``register_alias``; ``get`` and ``get_all`` are declared one level up on - :class:`EnumLookup` and reach it by inheritance. So a registry under - :mod:`pcapkit.const` gets all four from this module, apart from the +1. :class:`EnumRegistry` -- ``get``, ``get_all``, ``register`` and + ``register_alias``, in the form that suits a registry mapping one key to one + member. ``register`` and ``register_alias`` are its own; ``get`` and + ``get_all`` are declared one level up on :class:`EnumLookup` and reach it by + inheritance. So a registry under :mod:`pcapkit.const` gets all of them from + this module, apart from the overrides below and a few hand-written ``get`` overrides. -2. ``AppType``'s sub-base -- overrides all four, routing the two lookups +2. ``AppType``'s sub-base -- overrides each of them, routing the lookups through its ``_dispatch``, because a port lookup needs a transport protocol to be answerable at all. Defined not in this module but in :class:`pcapkit.const.reg.apptype.apptype.AppType` itself (GitHub issue @@ -65,16 +66,16 @@ ``register_alias`` are overridden without that dispatch, staying on the registry they are called on, so that a write never leaks onto a transport IANA never assigned the service to -- a minted member for the first, an - alias for the second. Plus ``_unregistered_member``, for its own three extra + alias for the second. Plus ``_unregistered_member``, for its own extra attributes (``svc``, ``port``, ``proto``) that the generic one below does not know to set. 3. The ``AppType`` transport subclasses -- ``TCP``, ``UDP``, ``SCTP``, ``DCCP`` -- need no override of their own at all: ``_dispatch`` already returns ``cls`` unchanged the moment ``cls.__registry__`` is not - :obj:`None`, which is true for exactly these four, so tier 2's lookups + :obj:`None`, which is true for exactly these subclasses, so tier 2's lookups already answer correctly on each of them without a further layer. -Defining the four methods here, rather than as generated *text* written out +Defining these methods here, rather than as generated *text* written out longhand in :data:`pcapkit.vendor.default.LINE` and copied into each crawler that replaces that template wholesale, is what :issue:`775` asks for: as text, adding one method means editing every bespoke template by hand. @@ -124,7 +125,7 @@ class EnumLookup: ``class Bar(EnumLookup, IntEnum)`` -- it contributes methods only, so :mod:`aenum` still resolves the member data type from the enumeration base: ``int`` for :class:`~aenum.IntEnum` and :class:`~aenum.IntFlag`, ``str`` for - :class:`~aenum.StrEnum`. That is what lets one base serve all three, where a + :class:`~aenum.StrEnum`. That is what lets one base serve each of them, where a generated template fragment would have needed a separate rendering per member type. @@ -134,11 +135,11 @@ class EnumLookup: EnumLookup -> IntFlag -> int -> ...``, so ``_member_type_`` still comes from the enumeration base and not from anything in this module. Had this tier subclassed :class:`~aenum.Enum` in order to "be an enum", it would have - become the member type itself and broken all three shapes at once. + become the member type itself and broken every one of these shapes at once. The methods deliberately touch only ``_member_map_``, ``_member_names_`` and ``_value2member_map_``, which both :mod:`enum` and :mod:`aenum` maintain, so - nothing on this tier depends on :mod:`aenum` internals at all -- the one + nothing on this tier depends on :mod:`aenum` internals at all -- the :func:`~aenum.extend_enum` call in this module belongs to :class:`EnumRegistry`, which is the tier that mutates. @@ -154,7 +155,7 @@ class EnumLookup: # NOTE: deliberately ``Any`` rather than ``type``. Annotating the member # data type precisely makes ``cls._member_type_.__new__(cls, value)`` # resolve to ``type.__new__``, which mypy then reads as building a - # *class* rather than an instance -- five errors for a call that is + # *class* rather than an instance -- mypy errors for a call that is # correct. Which concrete type it is depends on the Enum base each # subclass picks, so there is nothing more precise to say here anyway. _member_type_: 'Any' @@ -206,7 +207,7 @@ def _validate_value(cls, value: 'Any') -> 'None': message and the single log record it already emitted are what the caller sees. - Called from exactly two places, and the omissions are deliberate: + Called from the places below, and the omissions are deliberate: * :meth:`get`, immediately before ``cls(key)`` -- the one point at which a lookup can reach a subclass's ``_missing_`` and mint. The ``str``-key @@ -222,7 +223,7 @@ def _validate_value(cls, value: 'Any') -> 'None': :meth:`OptionType.register ` and :meth:`AppType.register ` - both call it at the same point. + each call it at the same point. :meth:`EnumRegistry.register_alias` does not call it, and does not need to: it refuses any ``value`` that is not already registered, so the value @@ -260,14 +261,14 @@ def get(cls, key: 'Any', default: 'Any' = NO_DEFAULT) -> 'Self': It never mints while resolving ``default``; ``key`` may still mint through a ``_missing_`` that GitHub issue :issue:`775`'s ruling - deliberately kept minting, on one registry (``CGAType``). Registering a member any other way is :meth:`register`'s job + deliberately kept minting, on ``CGAType``. Registering a member any other way is :meth:`register`'s job and nobody else's, which is the ruling :issue:`775` exists to carry out: an unrecognised or unregistered value does not become a registered member unless a user or caller explicitly creates one. A value inside a registry's declared-but-unassigned range still resolves, through that registry's own ``_missing_`` and :meth:`_unregistered_member`, to a member that is deliberately absent from the lookup tables -- true - outside the one registry named above, where such a value instead lands + outside ``CGAType``, where such a value instead lands in *both* tables, exactly as :meth:`register` would leave it -- for a non-``str`` key; the ``str`` case is qualified below. Both describe ``key`` resolution only. ``default`` never reaches ``_missing_`` on @@ -288,15 +289,15 @@ def get(cls, key: 'Any', default: 'Any' = NO_DEFAULT) -> 'Self': (:class:`~pcapkit.const.ftp.command.Command`, :class:`~pcapkit.const.ftp.command.FEATCode`, :class:`~pcapkit.const.http.method.Method`, :class:`~pcapkit.const.pcapng.option_type.OptionType`, - :class:`~pcapkit.const.reg.apptype.apptype.AppType` and its four + :class:`~pcapkit.const.reg.apptype.apptype.AppType` and its transport subclasses :class:`~pcapkit.const.reg.apptype.tcp.TCP`, :class:`~pcapkit.const.reg.apptype.udp.UDP`, :class:`~pcapkit.const.reg.apptype.sctp.SCTP` and :class:`~pcapkit.const.reg.apptype.dccp.DCCP`, and :class:`~pcapkit.const.pcapng.tls_key_label.TLSKeyLabel`) mints on - any path, so no live witness exists in this tree. The one registry - that still mints directly via :func:`~aenum.extend_enum`, - :class:`~pcapkit.const.mh.cga_type.CGAType`, is :class:`int`-valued, so + any path, so no live witness exists in this tree. + :class:`~pcapkit.const.mh.cga_type.CGAType`, which still mints directly + via :func:`~aenum.extend_enum`, is :class:`int`-valued, so a ``str`` name could not reach its mint branch even if this restriction did not exist; it is not an exception to it, just not reachable by it. This is about a future ``str``-valued registry (or a present one whose @@ -344,14 +345,14 @@ def get(cls, key: 'Any', default: 'Any' = NO_DEFAULT) -> 'Self': so every ``except KeyError`` and ``except ValueError`` around a call to this method catches. - Two details are worth stating, since neither is visible from the - exception type alone: + These details are worth stating, since the exception type alone does + not show them: * **The name miss is raised quietly** -- :exc:`~pcapkit.utilities.exceptions.EnumKeyError` with ``quiet=True``, so nothing is logged and :data:`sys.tracebacklimit` is left alone. That is not a cosmetic choice: this method's name miss is in-library - control flow at six call sites, and at + control flow, and at :meth:`~pcapkit.const.http.method.Method.get` it is part of a *successful* call -- that override catches it in order to build an unregistered member. A loud @@ -426,8 +427,9 @@ def get_all(cls, key: 'Any') -> 'tuple[Self, ...]': registry inheriting this base unmodified -- that tuple holds exactly one entry, since an alias registered by :meth:`register_alias` is a second *name* for the canonical member rather than a second member. The method - still exists here, because all four methods are to exist on every const - registry (GitHub issue :issue:`842`), and it is where a registry with genuinely + still exists here, because ``get``, ``get_all``, ``register`` and + ``register_alias`` are all to exist on every const registry (GitHub + issue :issue:`842`), and it is where a registry with genuinely several matches puts them: ``AppType`` overrides it to return every service IANA assigns to a port. @@ -465,7 +467,7 @@ class EnumRegistry(EnumLookup): issue :issue:`877` is what draws that line: an enumeration is immutable unless RFC or IANA says otherwise. - Mixed in ahead of the enum base exactly as before -- ``class + Mixed in ahead of the enum base -- ``class Foo(EnumRegistry, IntFlag)`` -- and gaining :class:`EnumLookup` as a parent does not disturb that: both tiers are plain classes, so ``_member_type_`` still resolves past them to the enumeration base. diff --git a/pcapkit/corekit/fields/collections.py b/pcapkit/corekit/fields/collections.py index e347e6c60..9d12671f5 100644 --- a/pcapkit/corekit/fields/collections.py +++ b/pcapkit/corekit/fields/collections.py @@ -78,7 +78,7 @@ class ListField(FieldBase[List[_TL]], Generic[_TL]): :meth:`self.__call__ `. This field is used to represent a list of fields, as in the case of lists of - constrant-length-field items in a protocol. + constant-length-field items in a protocol. """ @@ -294,7 +294,7 @@ class OptionField(ListField, Generic[_TS]): :meth:`self.unpack ` selects an option's schema by reading the ``type_name`` field of ``base_schema`` **alone** off the front of the option, instead of unpacking the whole base schema and keeping only that - one value. That is only the same read when three things hold of the type + one value. That is only the same read when the following hold of the type field: 1. it is the base schema's **first** field, so that it is what sits at the @@ -366,7 +366,7 @@ def __init__(self, length: 'int | Callable[[dict[str, Any]], int]' = lambda _: - # docstring above for what the fast path requires and why a base schema # that does not meet it is accommodated rather than rejected. # - # The three conditions are exactly what makes reading the type field alone + # The conditions above are exactly what makes reading the type field alone # the same read that ``Schema.unpack`` performs for it: it must sit at the # front of the option, ``Schema.unpack`` must handle it through its generic # branch rather than one of the special ones (a ``NumberField`` is never diff --git a/pcapkit/corekit/fields/ipaddress.py b/pcapkit/corekit/fields/ipaddress.py index 4f37010b5..db432b18c 100644 --- a/pcapkit/corekit/fields/ipaddress.py +++ b/pcapkit/corekit/fields/ipaddress.py @@ -178,7 +178,7 @@ def parse_ip_address(value: 'IPv4Address | IPv6Address | bytes | int | str', This raises :exc:`~pcapkit.utilities.exceptions.FieldValueError` and not :exc:`~pcapkit.utilities.exceptions.ProtocolError`, which is deliberate - even though two sibling guards for the same mistake -- + even though sibling guards for the same mistake -- :meth:`MH._make_opt_mn_id ` from :issue:`469` and :class:`ESP's SecurityAssociation @@ -187,10 +187,10 @@ def parse_ip_address(value: 'IPv4Address | IPv6Address | bytes | int | str', conversion, so it answers with what :meth:`_IPAddressField.pre_process` answers with for the identical value, and a caller sees one exception whether the :obj:`bool` reached the field through the schema or through - a ``_make_*``. The two protocol-level guards answer for the *option*, + a ``_make_*``. Those protocol-level guards answer for the *option*, alongside siblings that are not about addresses at all -- - ``_make_opt_mn_id`` refuses a :obj:`bool` for all eight MN-ID subtypes, - only one of which is address-typed -- so neither can route through here + ``_make_opt_mn_id`` refuses a :obj:`bool` for every MN-ID subtype, + address-typed or not -- so none of them can route through here without losing the subtype-aware message that is the point of it. Both exception classes derive from :exc:`~pcapkit.utilities.exceptions.BaseError` *and* :exc:`ValueError`, diff --git a/pcapkit/corekit/fields/misc.py b/pcapkit/corekit/fields/misc.py index 79218d5c1..76bdc680f 100644 --- a/pcapkit/corekit/fields/misc.py +++ b/pcapkit/corekit/fields/misc.py @@ -585,8 +585,8 @@ def nested_packet_context(packet: 'dict[str, Any]') -> 'dict[str, Any]': too, so handing a nested schema the enclosing mapping itself would let the inner ``length`` overwrite the outer one mid-pack. - Two consequences of it being a copy rather than a live view, both - deliberate and neither reached by any call site in this package. A name + Its being a copy rather than a live view has consequences, each + deliberate and none reached by any call site in this package. A name deleted from the returned mapping is simply gone, rather than reverting to the enclosing schema's value. And the copy is taken when this function is called, so a later mutation of ``packet`` is not diff --git a/pcapkit/corekit/fields/numbers.py b/pcapkit/corekit/fields/numbers.py index dd99d3539..f7ff4174b 100644 --- a/pcapkit/corekit/fields/numbers.py +++ b/pcapkit/corekit/fields/numbers.py @@ -375,7 +375,7 @@ def pre_process(self, value: 'int', packet: 'dict[str, Any]') -> 'int | bytes': one that captured them honours them; any other field, and any other value -- one a caller built, or the result of arithmetic on a parsed one, which is a plain :obj:`int` -- is truncated to - :attr:`bit_length` bits exactly as before. See GitHub issue + :attr:`bit_length` bits. See GitHub issue :issue:`1488`. """ @@ -427,7 +427,7 @@ def post_process(self, value: 'int | bytes', packet: 'dict[str, Any]') -> 'int': value the sign extension -- they are captured but uninterpreted, and the value records them (see :func:`_with_outside_bits`) so that packing it writes them back. Otherwise the value is a plain - :obj:`int`, as before. See GitHub issue :issue:`1488`. + :obj:`int`. See GitHub issue :issue:`1488`. """ if not self._need_process: @@ -843,8 +843,7 @@ def _unregistered_member(namespace: 'Type[StdlibEnum] | Type[AenumEnum]', :mod:`pcapkit.protocols.transport.transport` before passing it through unchanged (see ``test_a_member_is_still_an_apptype`` in ``tests/const/test_const_apptype_split_unit.py``); a value that - fails them would be a second defect standing in for the one this - fix removes. + fails them would be a defect of its own. The member this returns is absent from ``_value2member_map_``, so a *value*-keyed lookup on it -- ``self._namespace(value)`` -- @@ -857,8 +856,8 @@ def _unregistered_member(namespace: 'Type[StdlibEnum] | Type[AenumEnum]', builds an unregistered member of its own, through the registry's ``_unregistered_member`` -- measured on this tree, ``AppType.get(54321, proto=tcp)`` returns - ````, ``TCP.__members__`` stays at - 6147, and a second call with the same port returns an equal + ````, ``TCP.__members__`` does not + grow, and a second call with the same port returns an equal member rather than the same one. Two unregistered members for the same value also compare equal without being identical, since @@ -895,7 +894,7 @@ def _unregistered_member(namespace: 'Type[StdlibEnum] | Type[AenumEnum]', emulate 3.10, where those two do not exist. Rebuilding re-enters this method rather than ``namespace.__new__``, so an unpickled member is unregistered exactly as the original was and the - registry does not grow -- ``TCP.__members__`` measured at 6147 + registry does not grow -- ``TCP.__members__`` measured unchanged before and after. On 3.11+ ``copy``/``deepcopy`` still return the member itself, since ``Enum.__copy__`` short-circuits ahead of any reduction; on 3.10 they return an equal rebuilt one, which is @@ -1070,7 +1069,7 @@ def pre_process(self, value: 'int | AppType', packet: 'dict[str, Any]') -> 'int """ # NOTE: imported here rather than at module level, as # :mod:`pcapkit.const` itself imports :mod:`pcapkit.corekit`; and tested - # against AppType rather than ``self._namespace``, as the three + # against AppType rather than ``self._namespace``, as the # per-transport copies this class replaced did (:issue:`1516`). from pcapkit.const.reg.apptype import AppType # pylint: disable=import-outside-toplevel @@ -1112,7 +1111,7 @@ def post_process(self, value: 'int | bytes', packet: 'dict[str, Any]') -> 'AppTy That member carries the registry's own ``__transport__``, as ``get``'s does, rather than ``self._proto``. The two are the same - member for each of the three schemas, but a composite built by hand + member for each of the TCP, UDP and SCTP schemas, but a composite built by hand such as ``TransportProtocol.tcp | TransportProtocol.udp`` is a bare :class:`int` (``3``, which dispatches to SCTP), and reading ``.name`` off it would raise :exc:`AttributeError` on a miss ``get`` resolves. @@ -1127,7 +1126,7 @@ def post_process(self, value: 'int | bytes', packet: 'dict[str, Any]') -> 'AppTy catch keyed on exception type alone cannot see the difference between that and a "no member has this value", so it would quietly turn the rejection into a miss. Within the width, ``_missing_`` - raises for no port of any of the four registries: it returns a + raises for no port of any per-transport registry: it returns a member for a documented span and :data:`None` otherwise. Checking the width first needs no exception-based distinction at all. ``self.length`` is the field's own declared byte width (``2`` for diff --git a/pcapkit/corekit/fields/strings.py b/pcapkit/corekit/fields/strings.py index 1c9582000..92d81e908 100644 --- a/pcapkit/corekit/fields/strings.py +++ b/pcapkit/corekit/fields/strings.py @@ -128,9 +128,9 @@ class StringField(_TextField[str]): octet the charset cannot decode, a lossy ``errors`` scheme, or a URL quoting that differs from the original -- the field returns a :class:`DecodedString`, which remembers those octets and packs back as exactly them. The decoded - *text* is whatever it has always been, U+FFFD and all: a consumer that only - reads the text, such as a dumper writing it back out as UTF-8, sees no - change. A length of ``-1`` is resolved to the number of *encoded* octets. + *text* is the plain decoding, U+FFFD and all: a consumer that only reads + the text, such as a dumper writing it back out as UTF-8, sees an ordinary + :obj:`str`. A length of ``-1`` is resolved to the number of *encoded* octets. .. |chardet| replace:: ``chardet`` .. _chardet: https://chardet.readthedocs.io diff --git a/pcapkit/corekit/infoclass.py b/pcapkit/corekit/infoclass.py index 0ce2b840a..8ea28c2aa 100644 --- a/pcapkit/corekit/infoclass.py +++ b/pcapkit/corekit/infoclass.py @@ -781,14 +781,14 @@ class _MultiInfo(Info[VT], Generic[KT, VT]): live in the multi-mapping rather than in :attr:`~object.__dict__`. That is the whole carve-out from :class:`Info`, and it is confined to this - class and the two below it: + class and its subclasses, :class:`MultiInfo` and :class:`OrderedMultiInfo`: * :meth:`__new__` gives the multi-mapping its empty storage, and :meth:`__update__` *adds* every pair to it, so that the inherited :meth:`Info.from_dict` builds one; :func:`info_final` generates no ``__init__`` for such a class (it has no declared fields); * :meth:`__setattr__` admits the multi-mapping's own bookkeeping, and - only while one of those two is writing; + only while :meth:`__new__` or :meth:`__update__` is writing; * every mutator of the multi-mapping raises :exc:`~pcapkit.utilities.exceptions.UnsupportedCall`, as assignment to an :class:`Info` does; @@ -1083,8 +1083,8 @@ def _as_info_type(hint: 'Any') -> 'Optional[Type[Info]]': :class:`types.GenericAlias` such as ``list[Packet]`` satisfies ``isinstance(hint, type)`` while :func:`issubclass` still refuses it with :exc:`TypeError` -- which would otherwise escape - :meth:`Info.from_dict` for the 26 of 487 :class:`Info` classes that - carry such an annotation. From 3.11 on the ``isinstance`` is already + :meth:`Info.from_dict` for any :class:`Info` class that carries such an + annotation. From 3.11 on the ``isinstance`` is already :data:`False`, so only the older interpreters reach the :exc:`TypeError`; ``NestedTypeResolverTests`` in :file:`tests/corekit/test_from_dict_roundtrip_unit.py` pins the shape diff --git a/pcapkit/corekit/io.py b/pcapkit/corekit/io.py index bcca11ca9..40454aa5f 100644 --- a/pcapkit/corekit/io.py +++ b/pcapkit/corekit/io.py @@ -251,11 +251,11 @@ def _seek_buffer(self) -> 'int': The buffer is a sliding window whose octet 0 sits at absolute ``_buffer_set`` and whose content occupies ``[0:_buffer_cur]``, so ``_buffer_set + _buffer_cur`` is how - far the underlying stream has been consumed. Two things follow, and every buffered - read path needs both of them: + far the underlying stream has been consumed. Every buffered read path needs what + follows from that: * The buffer's own cursor is a **derived** quantity, ``_tell - _buffer_set``, rather - than a fourth piece of state to be maintained. Nothing keeps it in step: a read + than another piece of state to be maintained. Nothing keeps it in step: a read served from the stream writes through :attr:`_buffer_view` and leaves the cursor untouched, and :meth:`_write_buffer` rewinds it to the start of the appended octets when the window slides. Deriving it here, at each point of use, is what makes the drift @@ -557,7 +557,7 @@ def _truncate_buffer(self, size: 'int | None' = None, /) -> 'int': cannot be seeked: its octet 0 sits at absolute offset ``_buffer_set``, its content occupies ``[0:_buffer_cur]``, and everything past that is padding never read. - Two consequences for which octets survive. An extension appends its zero octets at + As for which octets survive: an extension appends its zero octets at the **tail**, the new area being by definition the region past the old end. A reduction below the content keeps the **most recent** ``size`` octets and advances ``_buffer_set`` past the ones it drops, because what this holds is lookback: the @@ -805,12 +805,12 @@ class PeekableStream: :class:`~pcapkit.foundation.extraction.Extractor` and the PCAP-NG engine read ahead with ``peek``, which :class:`io.BufferedReader` has and a plain - :class:`typing.IO` such as :class:`io.BytesIO` does not (#1506). The + :class:`typing.IO` such as :class:`io.BytesIO` does not (:issue:`1506`). The read-ahead is a read and a seek back, and every other attribute is the stream's own. It is not an :class:`io.IOBase`, so it has no finaliser that - could close the caller's stream behind their back (#610). + could close the caller's stream behind their back (:issue:`610`). - Copying and pickling follow the stream (#1524). :func:`copy.copy` gives a + Copying and pickling follow the stream (:issue:`1524`). :func:`copy.copy` gives a second proxy over the *same* stream, so the two share one position. :func:`copy.deepcopy` and :mod:`pickle` copy the stream too, so they work exactly when the stream itself can be deep-copied or pickled at that @@ -842,7 +842,7 @@ def peek(self, size: 'int' = 0) -> 'bytes': self._stream.seek(pos, io.SEEK_SET) def __getattr__(self, name: 'str') -> 'Any': - # NOTE: reached only for a name the proxy lacks, and two kinds are refused + # NOTE: reached only for a name the proxy lacks, and some names are refused # rather than forwarded. ``_stream`` is the proxy's own: :mod:`copy` and # :mod:`pickle` build an instance without :meth:`__init__`, so it is not set # yet, and forwarding would look it up through here again until the diff --git a/pcapkit/corekit/packet.py b/pcapkit/corekit/packet.py index 734317002..7161ea0e5 100644 --- a/pcapkit/corekit/packet.py +++ b/pcapkit/corekit/packet.py @@ -12,7 +12,7 @@ stream; most callers want neither, so both are postponed until somebody reads them. -A subclass keeps a three-part contract, which +A subclass keeps a contract, which :meth:`DeferredPacket.__init_subclass__` checks at class creation: * It is declared ``class X(DeferredPacket, Info)``, mixin first, so the methods @@ -76,7 +76,7 @@ class DeferredPacket: # undefined *on this mixin*, which is what a mixin is -- the base arrives at # the point of use, where every subclass is declared # ``class X(DeferredPacket, Info)`` and :class:`~pcapkit.corekit.infoclass.Info` - # supplies all three. Neither mypy nor pylint can see that from here, and + # supplies each of them. Neither mypy nor pylint can see that from here, and # pylint calls it an *error* rather than a warning. def __init_subclass__(cls, /, *args: 'Any', **kwargs: 'Any') -> 'None': diff --git a/pcapkit/corekit/sentinels.py b/pcapkit/corekit/sentinels.py index 36860f3d5..8e06d4547 100644 --- a/pcapkit/corekit/sentinels.py +++ b/pcapkit/corekit/sentinels.py @@ -10,11 +10,11 @@ that it can never be confused with a value a caller might legitimately pass. See the "Naming a Sentinel" section of :file:`docs/source/contributing/conventions/sentinel-convention.rst` for the -house rule the four below follow. +house rule the sentinels below follow. The owner's ruling on GitHub issue :issue:`911` chose one shared module over -one module per sentinel, and this module is the only import path for all -four: the module of the class that uses each one does not re-export it +one module per sentinel, and this module is the only import path for each +of them: the module of the class that uses each one does not re-export it (:issue:`1744`), per the ruling recorded on :issue:`1103` that a moved name keeps no re-export at its old path. :mod:`pcapkit.corekit.module`, :mod:`pcapkit.corekit.fields.field`, :mod:`pcapkit.corekit.enum` and @@ -314,9 +314,9 @@ class with no ``__eq__`` of its own does; what it lacks is a readable *absent* value, so reading falsy in a boolean context is the point. :data:`NO_DEFAULT` models something different: a marker meaning *no default was supplied*, checked exclusively by ``is`` at - :meth:`EnumLookup.get `'s two + :meth:`EnumLookup.get `'s comparison sites -- nothing here ever evaluates it for truthiness. Giving - it ``__bool__ -> False`` for symmetry with the other two would invite + it ``__bool__ -> False`` for symmetry with those two would invite exactly the conflation this sentinel exists to rule out: code that writes ``if not default:`` instead of ``if default is NO_DEFAULT:`` would then read :data:`NO_DEFAULT` the same way it reads a caller's genuine falsy diff --git a/pcapkit/vendor/__main__.py b/pcapkit/vendor/__main__.py index fd31c8697..6e9e64bad 100644 --- a/pcapkit/vendor/__main__.py +++ b/pcapkit/vendor/__main__.py @@ -85,8 +85,8 @@ def _snapshot_and_restore(vendor: 'Type[Vendor]') -> 'Iterator[None]': returns :data:`True`, the file is replaced, and nothing warns that no snapshot was ever taken. - That is one of two ways this function can decline to protect a target, - and the two are not symmetric. The other is :func:`tempfile.mkstemp` + That is one way this function can decline to protect a target. The + other, which does not mirror it, is :func:`tempfile.mkstemp` failing to create the backup file -- most commonly a destination directory with no write permission, which needs a *directory*-level operation this function performs (creating a new entry) that diff --git a/pcapkit/vendor/ftp/command.py b/pcapkit/vendor/ftp/command.py index 7897be905..83cbefc1d 100644 --- a/pcapkit/vendor/ftp/command.py +++ b/pcapkit/vendor/ftp/command.py @@ -72,7 +72,7 @@ class FEATCode(EnumRegistry, StrEnum): .. note:: Declares every FEAT keyword the IANA registry's own ``FEAT code`` - column names -- the 5 group markers below plus the per-command + column names -- the group markers below plus the per-command keywords generated after them (data-driven, not hand-picked; see :meth:`~pcapkit.vendor.ftp.command.Command.process`) -- rather than minting the per-command ones at import time as an incidental side @@ -129,9 +129,9 @@ def get(cls, key: 'Any', default: 'Any' = NO_DEFAULT) -> 'FEATCode': this is done, implementations are recommended to use upper case letters when transmitting the feature response."* A caller feeding a ``FEAT`` response line is therefore holding upper case by - recommendation, while 5 of this registry's 15 codes are registered in - lower case -- measured on the IANA CSV: 10 distinct all-upper-case - keywords against ``base``, ``feat``, ``hist``, ``nat6`` and ``secu``, + recommendation, while some of this registry's codes are registered in + lower case -- measured on the IANA CSV: ``base``, ``feat``, ``hist``, + ``nat6`` and ``secu``, against all-upper-case keywords for the rest, with none mixed. Without this override ``get('BASE')`` raised :exc:`KeyError`, which is the defect GitHub issue :issue:`903`'s audit found. @@ -286,7 +286,7 @@ class {NAME}(EnumRegistry, StrEnum): :meth:`register`, and ``get`` is not given enough information to create one. Concretely true here -- a bare wire command word carries no :attr:`feat`/:attr:`desc`/:attr:`type`/:attr:`conf`, so a minted member - had all four hollowed out to their defaults; :meth:`register` is the + had each of them hollowed out to its default; :meth:`register` is the path that can actually supply them. """ @@ -329,10 +329,10 @@ def _unregistered_member(cls, value: 'str', name: 'str') -> '{NAME}': entirely -- :meth:`~pcapkit.corekit.enum.EnumRegistry._unregistered_member` bypasses :meth:`__new__` (it calls - :class:`str`'s directly), so those four attributes would otherwise + :class:`str`'s directly), so those attributes would otherwise be absent and :meth:`__repr__` (which reads :attr:`desc`) would raise on the result. There is no more specific value to reconstruct - them from -- a bare wire command word carries none of the four, + them from -- a bare wire command word carries none of them, which is exactly the owner's reasoning for why ``get()``/ ``_missing_`` must not mint one: :meth:`register` is the path that can actually supply them. diff --git a/pcapkit/vendor/ftp/return_code.py b/pcapkit/vendor/ftp/return_code.py index d1da31cde..5d4c2ab0e 100644 --- a/pcapkit/vendor/ftp/return_code.py +++ b/pcapkit/vendor/ftp/return_code.py @@ -195,7 +195,7 @@ def _unregistered_member(cls, value: 'int', name: 'str') -> '{NAME}': same way :meth:`__new__` would, rather than leaving them unset -- :meth:`~pcapkit.corekit.enum.EnumRegistry._unregistered_member` bypasses :meth:`__new__` entirely (it calls :class:`int`'s directly), - so those three attributes would otherwise be missing from the result + so those attributes would otherwise be missing from the result and :meth:`__str__`/:meth:`__repr__` would raise on it. Args: diff --git a/pcapkit/vendor/http/method.py b/pcapkit/vendor/http/method.py index 13f657b12..ba63c0042 100644 --- a/pcapkit/vendor/http/method.py +++ b/pcapkit/vendor/http/method.py @@ -92,7 +92,7 @@ def _unregistered_member(cls, value: 'str', name: 'str') -> '{NAME}': :meth:`__new__` itself would, rather than missing entirely -- :meth:`~pcapkit.corekit.enum.EnumRegistry._unregistered_member` bypasses :meth:`__new__` (it calls :class:`str`'s directly), so - those two attributes would otherwise be absent. There is no more + those attributes would otherwise be absent. There is no more specific value to reconstruct them from -- a bare wire method verb carries neither, which is exactly the owner's reasoning for why ``get()``/``_missing_`` must not mint one: :meth:`register` is the @@ -234,8 +234,8 @@ def _missing_(cls, value: 'str') -> '{NAME}': :meth:`get`, which is case-**sensitive** per :rfc:`9110#section-9.1`. The split was ruled deliberate on GitHub issue :issue:`896`; GitHub issue :issue:`908` is the pointer between - the two, so a reader of this one file is not left with two - contradictory rationales and nothing tying them together. + the two, so the two rationales are not left contradicting each + other with nothing tying them together. """ if not isinstance(value, str): diff --git a/pcapkit/vendor/ipx/socket.py b/pcapkit/vendor/ipx/socket.py index d03f819e7..4aca94d58 100644 --- a/pcapkit/vendor/ipx/socket.py +++ b/pcapkit/vendor/ipx/socket.py @@ -119,7 +119,7 @@ # Processes", https://www.novell.com/documentation/nw6p/ipx_enu/data/hvvqznoa.html # -- still live. That page is also the citation the article itself used. # - # NOTE: Table 2 has **seven** rows and only five of them are below. In full + # NOTE: Table 2 has **seven** rows and not all of them are below. In full # it reads 0x451 NCP, 0x452 SAP, 0x453 RIP, 0x455 Novell NetBIOS, 0x456 # Diagnostics, 0x9001 NLSP, 0x9004 "IPXWAN(TM) protocol". The last two have # never been in this enumeration, and 0x9004 is independently reserved by @@ -132,7 +132,7 @@ # byte-identity proof this change rests on, which makes them a follow-up # rather than part of #507. # - # Two of the five below also depart from Novell's own wording: Novell writes + # Some of the rows below also depart from Novell's own wording: Novell writes # "Novell NetBIOS" and "Diagnostics" where this table says "NetBIOS" and # "Diagnostic Packet". Those are the archived revision's strings, kept for # the same member-renaming reason as everything else here. @@ -142,16 +142,16 @@ 0x0455: ('NetBIOS', 'NetBIOS'), 0x0456: ('Diagnostic Packet', 'Diagnostic Packet'), - # These two are the only rows the archived revision alone supplies: absent + # These are the only rows the archived revision alone supplies: absent # from Novell's Table 2, absent from the Xerox registry above, and absent # from every RFC swept. The sweep covered RFCs 1132, 1362, 1377, 1551, 1552, - # 1553, 1634, 1791, 1973 and 2043, looking for the five codes 0x0001, 0x0002, - # 0x0003, 0x0457 and 0x4003, and found 0 hits. (The first three of those five + # 1553, 1634, 1791, 1973 and 2043, looking for the codes 0x0001, 0x0002, + # 0x0003, 0x0457 and 0x4003, and found 0 hits. (0x0001, 0x0002 and 0x0003 # turned out to be sourced after all, just not from an RFC -- see the Xerox # note above.) # - # "0 hits" is a claim about those five codes and nothing more. Three of the - # ten RFCs do assign an IPX socket, 0x9004, which this table lacks; see the + # "0 hits" is a claim about those codes and nothing more. Some of the + # RFCs swept do assign an IPX socket, 0x9004, which this table lacks; see the # note on Novell's Table 2 above. # # 0x4003 is the weaker of the two: it falls inside Novell's own @@ -210,7 +210,7 @@ #: Socket number ranges, transcribed from the same revision as #: :data:`~pcapkit.vendor.ipx.socket.DATA`, as ``(start, stop, name)``. #: -#: Three of the five have a primary source, and it is not the archived +#: Some of these ranges have a primary source, and it is not the archived #: revision. Xerox, *Internet Transport Protocols*, XSIS 028112, December 1981, #: Appendix D: "The socket numbers zero and all ones are reserved to mean #: unknown and all, respectively. Well-known socket numbers have the range 1 to @@ -219,13 +219,13 @@ #: under a column header that the scan OCRs as ``goctalf`` and which reads #: "Well-Known Socket (octal)". #: -#: That reproduces the first three ranges exactly, and the arithmetic confirms +#: That reproduces the Xerox ranges exactly, and the arithmetic confirms #: the radix without having to trust that OCR: 3000 decimal is 0x0BB8, 3001 is -#: 0x0BB9, and octal 40-77 is 0x0020-0x003F -- all three as transcribed. Read as +#: 0x0BB9, and octal 40-77 is 0x0020-0x003F -- each as transcribed. Read as #: decimal instead, 40-77 would be 0x0028-0x004D, which is not what the table #: says. So the octal reading is settled by the numbers themselves. #: -#: Novell's *IPX Addressing* bears on the last two, and in opposite directions. +#: Novell's *IPX Addressing* bears on the remaining ranges, in opposite directions. #: ``(0x8000, 0xFFFF)`` matches it exactly -- "Socket numbers between 0x8000 and #: 0xFFFF are well-known sockets; these are assigned by Novell to specific #: processes." ``(0x4000, 0x4FFF)`` is *contradicted*, not merely rounded: the diff --git a/pcapkit/vendor/mh/__init__.py b/pcapkit/vendor/mh/__init__.py index 5a5ce5b4b..9c0cef34b 100644 --- a/pcapkit/vendor/mh/__init__.py +++ b/pcapkit/vendor/mh/__init__.py @@ -94,7 +94,7 @@ * - :class:`MH_CGASec ` - CGA SEC [*]_ * - :class:`MH_BindingError ` - - Bingding Error Status Code [*]_ + - Binding Error Status Code [*]_ .. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-1 .. [*] https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-2 diff --git a/pcapkit/vendor/ngap/__init__.py b/pcapkit/vendor/ngap/__init__.py index 1ded1323c..33d8b3b61 100644 --- a/pcapkit/vendor/ngap/__init__.py +++ b/pcapkit/vendor/ngap/__init__.py @@ -16,7 +16,7 @@ * - :class:`NGAP_ProtocolIE ` - NGAP Protocol IE Identifiers [*]_ -Both are sourced from |pycrate|_'s compiled NGAP specification rather than a +Each is sourced from |pycrate|_'s compiled NGAP specification rather than a network registry -- see :mod:`pcapkit.vendor.ngap.procedure_code`'s module docstring for why, and GitHub issue :issue:`880` for the ruling. diff --git a/pcapkit/vendor/ngap/procedure_code.py b/pcapkit/vendor/ngap/procedure_code.py index d8998d501..f00b301e8 100644 --- a/pcapkit/vendor/ngap/procedure_code.py +++ b/pcapkit/vendor/ngap/procedure_code.py @@ -17,8 +17,9 @@ or ``ProtocolIE-ID`` open type it belongs to) -- and it is the very same dependency :mod:`pcapkit.protocols.application.ngap` already needs installed to decode NGAP at all. So this crawler reads that already-installed package -directly instead of fetching anything over the network: :attr:`~ProcedureCode.LINK` -is :obj:`None` and :meth:`ProcedureCode._request` imports ``pycrate_asn1dir.NGAP`` +directly instead of fetching anything over the network: it leaves +:attr:`~pcapkit.vendor.default.Vendor.LINK` at its :obj:`None` default, and +:meth:`ProcedureCode._request` imports ``pycrate_asn1dir.NGAP`` in place of :meth:`~pcapkit.vendor.default.Vendor._request`'s HTTP round trip. No network access happens at generation time -- only, if at all, whenever ``pip install pypcapkit[NGAP]`` last ran. @@ -145,7 +146,7 @@ def _request(self) -> 'list[tuple[str, int]]': # type: ignore[override] naming which ``NGAP-CommonDataTypes`` open type it belongs to (``.called``, a ``(module, type)`` pair), a private ``_name`` holding the ASN.1 identifier verbatim (``'id-AMFConfigurationUpdate'``), and a private - ``_val`` holding the assigned integer. None of the three has a public + ``_val`` holding the assigned integer. None of these has a public accessor that survives this far: :meth:`~pycrate_asn1rt.asnobj.ASN1Obj.get_typeref` resolves to the *referenced type object* rather than its @@ -195,7 +196,7 @@ def count(self, data: 'list[tuple[str, int]]') -> 'Counter[str]': # type: ignor Unlike a hand-scraped CSV, |pycrate|_'s compiled specification names each assignment once -- measured, zero duplicate names and zero - duplicate values across all 81 -- so + duplicate values across every assignment -- so :meth:`~pcapkit.vendor.default.Vendor.rename`'s per-name counter has nothing to disambiguate and this crawler never calls it. diff --git a/pcapkit/vendor/ngap/protocol_ie.py b/pcapkit/vendor/ngap/protocol_ie.py index 4f09de4a3..2316b1242 100644 --- a/pcapkit/vendor/ngap/protocol_ie.py +++ b/pcapkit/vendor/ngap/protocol_ie.py @@ -125,7 +125,7 @@ def _request(self) -> 'list[tuple[str, int]]': # type: ignore[override] """Read the assignment from |pycrate|_'s compiled NGAP specification. See :meth:`pcapkit.vendor.ngap.procedure_code.ProcedureCode._request` - for why the three private attributes read here (``_typeref``, + for why the private attributes read here (``_typeref``, ``_name``, ``_val``) have no surviving public equivalent. Returns: @@ -166,8 +166,8 @@ def count(self, data: 'list[tuple[str, int]]') -> 'Counter[str]': # type: ignor """No duplicate-name bookkeeping needed. See :meth:`pcapkit.vendor.ngap.procedure_code.ProcedureCode.count` -- - measured, zero duplicate names and zero duplicate values across all - 438. + measured, zero duplicate names and zero duplicate values across every + assignment. """ return collections.Counter() diff --git a/pcapkit/vendor/pcapng/block_type.py b/pcapkit/vendor/pcapng/block_type.py index 602329f18..97cbfae14 100644 --- a/pcapkit/vendor/pcapng/block_type.py +++ b/pcapkit/vendor/pcapng/block_type.py @@ -25,9 +25,9 @@ from bs4.element import Tag ############################################################################### -# NOTE: on the registry URL, which this module and its two siblings +# NOTE: on the registry URL, which this module and its siblings # (:mod:`~pcapkit.vendor.pcapng.option_type`, -# :mod:`~pcapkit.vendor.pcapng.record_type`) share. Why all three read ``-03`` is +# :mod:`~pcapkit.vendor.pcapng.record_type`) share. Why they all read ``-03`` is # stated for readers in the note in ``docs/source/pcapkit/vendor/pcapng.rst``, # which renders; what follows is the measurement detail behind it. See #518. # @@ -39,9 +39,9 @@ # the only HTML ``
`` is the running-header one, so # ``soup.select('table#table-9')`` below finds nothing and raises ``IndexError``. # Measured across every published revision, ``-03`` is the only one that -# reproduces all three committed constant files byte for byte. +# reproduces every committed constant file byte for byte. # -# Two renderings of ``-03`` were compared, and both reproduce the three constant +# Two renderings of ``-03`` were compared, and both reproduce the constant # files byte-identically, so the choice is about exposure rather than data: # # * https://www.ietf.org/archive/id/draft-tuexen-opsawg-pcapng-03.html diff --git a/pcapkit/vendor/pcapng/tls_key_label.py b/pcapkit/vendor/pcapng/tls_key_label.py index 4fa297095..7c04fa748 100644 --- a/pcapkit/vendor/pcapng/tls_key_label.py +++ b/pcapkit/vendor/pcapng/tls_key_label.py @@ -173,8 +173,8 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': # such member carried in the hand-written # ``pcapkit.protocols.misc.pcapng.TLSKeyLabel`` (#882) -- # bandit's B105 (hardcoded password string) flags a string - # constant assigned to a name containing ``SECRET``, which eight - # of these ten labels' names do. + # constant assigned to a name containing ``SECRET``, which most + # of these labels' names do. if 'SECRET' in label: pref += ' # nosec B105' diff --git a/pcapkit/vendor/reg/apptype/apptype.py b/pcapkit/vendor/reg/apptype/apptype.py index 638eb8cdc..99110fd06 100644 --- a/pcapkit/vendor/reg/apptype/apptype.py +++ b/pcapkit/vendor/reg/apptype/apptype.py @@ -7,9 +7,9 @@ This module contains the vendor crawler for **Application Layer Protocol Numbers**, which is automatically generating :class:`pcapkit.const.reg.apptype.apptype.AppType`. -It also carries the machinery the four per-transport crawlers in this package +It also carries the machinery the per-transport crawlers in this package share -- the one pass over IANA's CSV that groups its rows, and the templates -that render them -- since all five read the same registry and differ only in +that render them -- since they all read the same registry and differ only in which rows they claim. See :class:`~pcapkit.vendor.reg.apptype.tcp.TCP` and its siblings for those. @@ -41,9 +41,9 @@ #: Per-process cache of the parsed registry, keyed by :attr:`Vendor.LINK`. #: -#: The five crawlers in this package read one 1.1 MB CSV between them, and +#: The crawlers in this package all read the same IANA CSV, and #: :meth:`Vendor._request` is per-instance, so ``pcapkit-vendor`` would otherwise -#: fetch the same file from IANA five times in a row for a single run. +#: fetch the same file from IANA once per crawler in a single run. _CACHE = {} # type: dict[str, list[str]] #: The canonical service for each port IANA assigns more than one to, per @@ -52,9 +52,8 @@ #: IANA genuinely registers three services on TCP/80 -- ``http``, ``www`` and #: ``www-http`` -- and gives no precedence among them, so the registry cannot #: derive which one a port lookup should answer with. Registry row order does not -#: supply it either: taken alone it answers 28 of these 44 pairs the way the rest -#: of the world does and 16 of them differently, giving ``l2f`` for 1701 and -#: ``shilp`` for 2049. +#: supply it either: taken alone it answers many of these pairs differently +#: from the rest of the world, giving ``l2f`` for 1701 and ``shilp`` for 2049. #: #: So this follows the industry convention instead, taken from :file:`/etc/services` #: -- the same answer :func:`socket.getservbyport` gives. Each entry is the first @@ -335,8 +334,8 @@ class {NAME}(EnumRegistry, StrEnum): .. versionchanged:: 1.5.0 Split by transport protocol (:issue:`732`): :mod:`pcapkit.const.reg.apptype` - is a package, and every assignment is a member of one of the four - registries above rather than of this class. ``get()`` raises + is a package, and every assignment is a member of one of the per-transport + registries rather than of this class. ``get()`` raises :exc:`ValueError` for a port outside ``0``-``65535`` (:issue:`758`), and returns an unregistered member rather than minting one for a port the registry does not assign (:issue:`860`). @@ -372,15 +371,15 @@ class {NAME}(EnumRegistry, StrEnum): #: the last of them. #: #: Declared here as :obj:`None` and overridden in each subclass: a mutable - #: class attribute declared on this class would be *shared* by all four - #: subclasses, so they would collide with each other exactly as the ports of + #: class attribute declared on this class would be *shared* by every + #: subclass, so they would collide with each other exactly as the ports of #: one transport used to collide inside the old flat registry. __registry__: 'Optional[MultiDict[int, {NAME}]]' = None #: Registry class owning each transport protocol, i.e. what #: :meth:`get` delegates to when called on this class rather than on one of - #: them. Populated by :mod:`pcapkit.const.reg.apptype` once all four have - #: been imported, since this module cannot import its own subclasses. + #: them. Populated by :mod:`pcapkit.const.reg.apptype` once every one of + #: them has been imported, since this module cannot import its own subclasses. __registries__: 'dict[TransportProtocol, Type[{NAME}]]' = {{}} #: Canonical service per port, for the ports carrying more than one. The base @@ -412,7 +411,7 @@ def __new__(cls, value: 'int', name: 'str' = '', def aliases(self) -> 'tuple[{NAME}, ...]': """Other services sharing :attr:`port` in this member's own registry. - GitHub issue :issue:`807`. No storage of its own: IANA already keeps every + GitHub issue :issue:`807`. No storage of its own: the registry already keeps every colliding service as its own member of :data:`__registry__`, keyed on the shared port -- :meth:`get_all` already walks that same bucket to answer with the aliases after the canonical member, so this is exactly @@ -459,7 +458,7 @@ def __str__(self) -> 'str': # consequence worth stating plainly rather than leaving for a doctest # to trip over: ``str(member) == member.value`` already breaks at # class-creation time for every port that statically carries more - # than one service (94 such members as shipped); + # than one service; # :meth:`register_alias` merely adds to that set at runtime. base = f'{{self.svc}} [{{self.port}} - {{self.proto.name}}]' aliases = self.aliases @@ -538,7 +537,7 @@ def _dispatch(cls, key: 'int', proto: 'TransportProtocol | str | int') -> 'Type[ proto = TransportProtocol.get(proto.lower()) # NOTE: a direct dict lookup covers every genuine single transport -- - # one of the four real members, or a bare int equal to one of their + # one of the real members, or a bare int equal to one of their # values -- since ``__registries__`` keys compare by the same # int-valued hash/eq every member and bare int alike already use. The # cast is for mypy alone: ``dict.get`` accepts any hashable key at run @@ -554,7 +553,7 @@ def _dispatch(cls, key: 'int', proto: 'TransportProtocol | str | int') -> 'Type[ # member's value at the dict lookup above, and nothing below decodes # ``proto``'s bits looking for a partial answer either -- on either # numbering. A genuine member reaching this point is ``undefined`` -- - # the four real transports would already have resolved above, and + # a real transport would already have resolved above, and # :meth:`TransportProtocol.get` cannot mint anything else, per the # maintainer ruling given in review of the work for #808, against # extending TransportProtocol at all -- and a bare :class:`int` reaches @@ -680,7 +679,7 @@ def get_all(cls, key: 'int', *, Returns: The canonical member followed by its aliases, in registry row order. Never empty: a port with no assignment goes through :meth:`get`, so it - is minted rather than answered with an empty result. + is answered with an unregistered member rather than an empty result. Raises: ValueError: As :meth:`get`. @@ -786,8 +785,8 @@ def register(cls, port: 'int', name: 'str') -> '{NAME}': # pylint: disable=argu Raises: ValueError: If called on a class that holds no members, i.e. on - :class:`{NAME}` itself, which is not one of the four - per-transport registries; if ``port`` already carries a + :class:`{NAME}` itself, which is not a + per-transport registry; if ``port`` already carries a member of this registry; if ``name`` sanitises to text that is not a valid Python identifier at all; or if the identifier it does sanitise to already names an unrelated member of this @@ -840,7 +839,7 @@ def register_alias(cls, port: 'int', name: 'str') -> '{NAME}': # pylint: disabl The Python attribute name is derived from ``name`` through :meth:`_sanitize_identifier`. It has to be ``name``, not ``port`` and - a counter: an alias whose own name does not resolve through + a counter: an alias whose own name resolves through subscription is most of the point of registering one, and ``TCP['www_http']`` resolving is exactly what lets a caller reach an alias the same way every statically declared member already is. @@ -861,8 +860,8 @@ def register_alias(cls, port: 'int', name: 'str') -> '{NAME}': # pylint: disabl Raises: ValueError: If called on a class that holds no members, i.e. on - :class:`{NAME}` itself, which is not one of the four - per-transport registries; if ``port`` carries no member of + :class:`{NAME}` itself, which is not a + per-transport registry; if ``port`` carries no member of this registry yet; if ``name`` already names one of the members already there; if ``name`` sanitises to text that is not a valid Python identifier at all -- empty, or leading with @@ -881,9 +880,9 @@ def register_alias(cls, port: 'int', name: 'str') -> '{NAME}': # pylint: disabl if any(member.svc == name for member in existing): raise ValueError(f'{{name!r}} is already registered on port {{port}} of {{cls.__name__}}') - # NOTE: the 58 members the generator mints via safe_name's own + # NOTE: the members the generator mints via safe_name's own # fallback -- ``{{cls.__name__}}_{{residue}}``, when the sanitised - # residue is not a valid identifier (28 TCP, 29 UDP, 1 SCTP, 0 DCCP) -- + # residue is not a valid identifier -- # are names this runtime path refuses rather than accepts: that # fallback is deliberately not reproduced in # :meth:`_sanitize_identifier`, which raises here instead (see Raises @@ -920,7 +919,7 @@ def _unregistered_member(cls, value: 'int', name: 'str', :meth:`~pcapkit.corekit.enum.EnumRegistry._unregistered_member` bypasses :meth:`__new__` entirely (it builds through ``cls._member_type_.__new__`` directly), so this - class's own three attributes would otherwise be missing and every + class's own attributes (``svc``, ``port``, ``proto``) would otherwise be missing and every method reading them (:meth:`__repr__`, :meth:`__str__`, :meth:`__int__`, the comparison operators, :attr:`aliases`) would raise on the result. Deliberately *not* added to :data:`__registry__` -- unlike @@ -976,7 +975,7 @@ def _missing_(cls, value: 'int') -> 'Optional[{NAME}]': {'' if ''.join(MISS.splitlines()[-1:]).startswith('return') else 'return super()._missing_(value)'} '''.strip() # type: Callable[[str, str, str, str, str, str], str] -#: Template for a per-transport registry, i.e. the four modules holding the +#: Template for a per-transport registry, i.e. each module holding the #: members of one transport protocol and nothing else. TRANSPORT = lambda NAME, DOCS, PROTO, CANON, TABLE, ENUM, MODL: f'''\ # -*- coding: utf-8 -*- @@ -1019,7 +1018,7 @@ class {NAME}(AppType): __transport__: 'TransportProtocol' = TransportProtocol.{PROTO} #: Members of this registry, keyed on port number. Declared per registry - #: rather than inherited, since one mapping shared by all four would put + #: rather than inherited, since one mapping shared by every registry would put #: every transport's ports in the same key space. __registry__: 'MultiDict[int, {NAME}]' = MultiDict() @@ -1239,8 +1238,8 @@ def records(self, data: 'list[str]') -> 'tuple[OrderedDict[str, Record], list[st # NOTE: a span IANA assigns to a transport protocol is claimed by # that registry alone, through a test on ``cls.__transport__``. - # Source order decided instead until GitHub issue #760: the only - # two spans registered on more than one transport -- 6000-6063 and + # Source order decided instead until GitHub issue #760: the + # spans registered on more than one transport -- 6000-6063 and # 6665-6669 -- rendered the same condition twice, leaving the # second copy unreachable, so *every* registry answered with the # first row's. That is not merely a duplicate to collapse: the @@ -1250,7 +1249,7 @@ def records(self, data: 'list[str]') -> 'tuple[OrderedDict[str, Record], list[st # # A span naming no transport protocol is an unassigned or reserved # marker belonging to whichever registry was asked, so it carries - # no test and keeps answering all four. + # no test and keeps answering every registry. flag = self.flag([proto]) claim = '' if proto == 'undefined' else f' and cls.__transport__ is {flag}' @@ -1299,7 +1298,7 @@ def process(self, data: 'list[str]') -> 'tuple[list[str], list[str]]': # ``record.protos`` here instead put the whole # ``(service, port)`` IANA set on every member, which made # ``TCP.http.proto`` name UDP and SCTP as well. That was a second - # copy of what the four registries already encode, it is the copy + # copy of what the per-transport registries already encode, it is the copy # that could drift, and being multi-bit it was refused by every # entry point that consumed it. pres = f"{key} = {record.port}, {record.svc!r}, {self.flag([self.TRANSPORT])}" diff --git a/pcapkit/vendor/reg/linktype.py b/pcapkit/vendor/reg/linktype.py index e4b1ee167..b8760ded4 100644 --- a/pcapkit/vendor/reg/linktype.py +++ b/pcapkit/vendor/reg/linktype.py @@ -170,7 +170,7 @@ def _expand(temp: 'str') -> 'list[int]': # member always lands in ``enum`` unconditionally, # rather than through the per-row ``sink`` above. # Otherwise one range row whose notes happened to mention - # "legacy" would sink all sixteen expanded members at + # "legacy" would sink every member it expands to at # once instead of just itself (item 2 in #852). enum.append(f'{sufs}\n {pres}')