Tier 3 of the post-1.3.0 roadmap. Target version: 2.1.0 (minor).
Typing is the niche nobody else occupies. A good deal of claiming it is
a writing problem, not a code problem.
| # |
Item |
| #93 |
Document structural pattern matching — it already works |
| #94 |
Curate __match_args__ for the wide headers |
| #95 |
Enum accessors alongside the int fields |
| #96 |
Turn the remaining display strings into typed values |
Start with #93, which costs nothing
match/case dissection works on our headers today, with no code
changes, because frozen dataclasses auto-generate __match_args__ and
IntEnum subclasses int. It appears in no documentation anywhere.
This is the most distinctive thing about the library and it is
currently invisible.
The niche, concretely
No library on PyPI combines: zero dependencies, frozen-dataclass
headers, IntEnum field values, __match_args__-driven match/case
dissection, and py.typed with real (non-Any) field types under
mypy --strict. The single neighbour is PyTCP-net_proto — GPL-3.0,
Python ≥3.14, Alpha, one dependency, carved out of a TCP/IP stack.
For contrast, under mypy --strict: scapy accepts
p.ThisFieldDoesNotExist with no error (every field is Any via
__getattr__), and dpkt cannot be analysed at all (no py.typed).
We catch ip.proto and suggest protocol.
One deliberate non-goal
Do not retype the wire fields as enums. ethertype: EtherType is
the obvious move and the wrong one — an IntEnum field cannot hold an
unrecognized value, and round-trip fidelity for unknown protocol
numbers is worth more than the annotation. #95 adds accessors instead,
mirroring the src_address pattern 1.3.0 already established.
#94 depends on #93. #95 and #96 are independent; #96 is really four
separate pieces of work and should be split into separate PRs.
Part of the post-1.3.0 roadmap: #107
Tier 3 of the post-1.3.0 roadmap. Target version: 2.1.0 (minor).
Typing is the niche nobody else occupies. A good deal of claiming it is
a writing problem, not a code problem.
__match_args__for the wide headersStart with #93, which costs nothing
match/casedissection works on our headers today, with no codechanges, because frozen dataclasses auto-generate
__match_args__andIntEnumsubclassesint. It appears in no documentation anywhere.This is the most distinctive thing about the library and it is
currently invisible.
The niche, concretely
No library on PyPI combines: zero dependencies, frozen-dataclass
headers,
IntEnumfield values,__match_args__-drivenmatch/casedissection, and
py.typedwith real (non-Any) field types undermypy --strict. The single neighbour isPyTCP-net_proto— GPL-3.0,Python ≥3.14, Alpha, one dependency, carved out of a TCP/IP stack.
For contrast, under
mypy --strict: scapy acceptsp.ThisFieldDoesNotExistwith no error (every field isAnyvia__getattr__), and dpkt cannot be analysed at all (nopy.typed).We catch
ip.protoand suggestprotocol.One deliberate non-goal
Do not retype the wire fields as enums.
ethertype: EtherTypeisthe obvious move and the wrong one — an
IntEnumfield cannot hold anunrecognized value, and round-trip fidelity for unknown protocol
numbers is worth more than the annotation. #95 adds accessors instead,
mirroring the
src_addresspattern 1.3.0 already established.#94 depends on #93. #95 and #96 are independent; #96 is really four
separate pieces of work and should be split into separate PRs.
Part of the post-1.3.0 roadmap: #107