Repository navigation
refactor(corekit): share one PortEnumField across TCP, UDP and SCTP (#1516) - #1526
Merged
Merged
Conversation
…1516) - corekit.fields.numbers: add a public PortEnumField beside EnumField. It takes a keyword-only proto, the TransportProtocol member its ports belong to; its pre_process and post_process are the three copies' bodies, with that member in place of the hard-coded one. - schema/transport/{tcp,udp,sctp}: drop the local PortEnumField classes, which an AST diff shows differed only in that member, and pass each schema's own transport to the shared field. - docs: document it on the numbers page and in the fields class diagram; repoint the cross-references to the removed classes. - tests: new unit tests pin the per-transport lookup, an unassigned port, pack and unpack; the existing callers pass proto, the field round-trip table gets one case per transport, and the composite-proto sweep follows the lookups into numbers.py and pins the six constructor calls. Behaviour is byte-identical on the 1398 TCP, UDP and SCTP layers of examples/captures/*. Refs #1516
Contributor
|
Coverage: 90.10% (unit tier, Python 3.14,
Per-file detail: the |
Owner
Author
|
Verdict: GOOD TO GO at
Non-blocking:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Please follow the guide below
make pylint,make mypy,make isort)make testpasses, and a test case covers the changeWhat is the purpose of your pull request?
refactor— changes neither behaviour nor performanceDescription of your pull request and other information
The three
PortEnumFieldclasses inschema/transport/{tcp,udp,sctp}.pywere AST-identical apart from theTransportProtocolmember inpost_process. They become one publicPortEnumFieldincorekit/fields/numbers.py, besideEnumField, with a keyword-onlyproto. Each schema passes its own. It is documented on the numbers page and in the fields class diagram.examples/captures/*(1261/103/34) give the same octets and port members before and after. That covers parse→rebuild,from_data(info.to_dict()), and make→parse from members and from bare ports. Digest sha256010bd641…both times.tests/corekit/test_fields_numbers_port_enum_field_1516_unit.pyhas 7 tests, and all 7 fail onmain. A mutant that ignoresprotofails 5 subtests. Updated: the existing callers of the old classes, the field round-trip table, and the composite-protosweep intests/const.corekit.fields: doing so forcesPortEnumFieldintocorekit/__init__.py's__all__, which refactor(corekit)!: Info.to_dict() returns an OrderedMultiDict; add MultiInfo and OrderedMultiInfo (#1484) #1523 has in flight (test_public_apifails otherwise).SwitchFieldsets the precedent.tests/corekit,tests/protocols/transport, eachtests/protocols/test_*roundtrip*,tests/project,tests/test_docstring_contract.py,tests/test_tier_guard.py, plus the touchedtests/constandtests/dumpkitmodules. All pass.Refs #1516