Repository navigation
refactor(protocols): make annotations and __all__ agree with what the code stores (#2317) - #2377
Conversation
… code stores (#2317) Problem: nine declarations described a value the code never produces, so mypy and the rendered docs were wrong about it -- `CALIPSOOption.cmpt_bitmap` typed `bytes` where `_read_opt_calipso` stores a tuple of ints, `SMFHashBasedDPDOption.post_process` declaring its sibling's schema, `Optional` on an `RR`/`SSR` `route` that is always built, `protochain` declaring a `ProtoChain` that `NoPayload` does not have, the `pack_flags` constructor stub typing the EPB flags, `ARP._make_addr_resolve` omitting the `bytearray` its body handles, an undeclared `entry_raw`, two HIP parameters missing from both `__all__` lists, and a `version` one `_read_param_*` took positionally. Fix: each declaration now matches the value. `NoPayload` overrides `protochain` as `-> 'None'`, the way it narrows `name`; `entry_raw` is declared under `TYPE_CHECKING`, as IPv4 declares `trailer`; `OverlayTTLParameter` and `ViaRVSParameter` join the HIP `__all__` lists and the package re-exports those lists require. Parsing and rebuilding are unchanged. Test: tests/protocols/test_declarations_match_values_2317_unit.py pins each declaration against the value it describes -- a parse for what is stored, and the source for a declaration that lives only under `TYPE_CHECKING`. All nine cases fail on the parent commit.
|
Coverage: 91.58% (unit tier, Python 3.15,
Per-file detail: the |
|
Review: GOOD TO GO at |
|
Ready to merge. Review: GOOD TO GO (Sonnet) at |
make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
refactor — code refactoringDescription
Closes #2317.
CALIPSOOption.cmpt_bitmaptypedbyteswhere_read_opt_calipsostores a tuple of ints,SMFHashBasedDPDOption.post_processdeclaring its sibling's schema,Optionalon anRR/SSRroutethat is always built,protochaindeclaring aProtoChainthatNoPayloaddoes not have, thepack_flagsconstructor stub typing the EPB flags,ARP._make_addr_resolveomitting thebytearrayits body handles, an undeclaredentry_raw, two HIP parameters missing from both__all__lists, and aversionone_read_param_*took positionally.NoPayloadoverridesprotochainas-> 'None', the way it narrowsname;entry_rawis declared underTYPE_CHECKING, as IPv4 declarestrailer;OverlayTTLParameterandViaRVSParameterjoin the HIP__all__lists and the package re-exports those lists require. Parsing and rebuilding are unchanged.tests/protocols/test_declarations_match_values_2317_unit.pypins each declaration against the value it describes — a parse for what is stored, and the source for a declaration that lives only underTYPE_CHECKING. All nine cases fail on the parent commit.