Skip to content

refactor(interface): make the registry-entry helpers public in pcapkit.interface.registry (#1519) - #1568

Merged
JarryShaw merged 1 commit into
mainfrom
refactor/1519-interface-registry-helpers
Oct 10, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
refactor/1519-interface-registry-helpers

Conversation

@JarryShaw

Copy link
Copy Markdown
Owner

Please follow the guide below

What is the purpose of your pull request?

Tick the commit type your subject line carries.

  • fix — corrects a defect
  • feat — adds a feature
  • perf — changes performance, not behaviour
  • refactor — changes neither behaviour nor performance
  • test — tests only
  • docs — documentation only
  • ci — workflows or build tooling
  • release — bumps the version or rolls up a distribution
  • chore — anything else

Description of your pull request and other information

  • Move: _same_entry, _restore_shipped and _restore_shipped_dumper leave foundation/extraction.py for the new pcapkit/interface/registry.py. Their public names are same_entry, restore_shipped and restore_shipped_dumper, and the bodies are unchanged. I named the module after what the helpers operate on, keeping the one-word style of core and misc.
  • Callers: extraction.py imports the helpers at top level, and its eight call sites use the public names. The lazy import in TraceFlowBase.register_dumper now points at the new module and stays inside the function. It no longer needs to: hoisting it to top level imports cleanly from every entry point.
  • Public surface: the helpers are not re-exported from pcapkit.interface or pcapkit. They are registrar plumbing, and pcapkit.interface.misc is not re-exported either. pcapkit.__all__ is unchanged.
  • Docs: there is a new interface/registry.rst page, listed in the interface toctree and table.
  • Tests: tests/interface/test_registry.py has 15 tests and all 15 fail on origin/main (module missing). Five mutations of the helpers, such as an asymmetric same_entry, a dropped silent no-op, or a subscript lookup on a defaultdict, are each caught. Coverage of registry.py is 100% of lines and branches. With the traceflow.py edit reverted, 2 tests in test_restore_builtin_unit.py fail with ImportError.

Closes #1519

…t.interface.registry (#1519)

- `_same_entry`, `_restore_shipped` and `_restore_shipped_dumper` move out of
  `pcapkit.foundation.extraction` into the new `pcapkit.interface.registry`
  as `same_entry`, `restore_shipped` and `restore_shipped_dumper`. The bodies
  are unchanged; the docstrings now state the contract in full.
- `extraction.py` imports them at top level, and the lazy import in
  `TraceFlowBase.register_dumper` now names the new module.
- They are not re-exported from `pcapkit.interface` or `pcapkit`, the same
  as `pcapkit.interface.misc`.
- New `docs/source/pcapkit/interface/registry.rst`, added to the interface
  toctree and table.
- `tests/interface/test_registry.py` pins each helper's contract (15 tests).
@JarryShaw JarryShaw added refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix) review: running A cross-review is in flight against the current head - no verdict yet labels Oct 10, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at 693702786. Cross-reviewed on Sonnet; the author ran Opus.

  • Behaviour is unchanged: each moved function's AST is identical to main's, apart from the renames and two added docstring sentences. No old underscore name is left anywhere in the tree. All 8 call sites and the lazy import in traceflow.py:246 point to the new module.
  • No import cycle: 12 entry points each import first in a fresh interpreter. pcapkit.__all__ (64 names) and dir(pcapkit) (93) match main.
  • Docs: a full nitpicky Sphinx build shows no new warnings, and every link on the new page resolves.
  • Fail-before: tests/interface/test_registry.py gives 15 failed on main. test_restore_builtin_unit.py gives 2 failed with main's traceflow.py.
  • Tests: these pass: interface (35), registry (43), extraction (36), traceflow (45), public API and isolation (16), and the project guards (130+).
  • Closes #1519: every inventory row is accounted for: refactor(schema): share the IPv6-option and byte-order schema helpers (#1519) #1528, refactor(http): move test_start_line and its patterns into the http base module (#1519) #1525, the packet2chain ruling, and this PR.

Non-blocking:

@JarryShaw JarryShaw added review: good-to-go Cross-review at the current head says ready; CI state is separate and removed review: running A cross-review is in flight against the current head - no verdict yet labels Oct 10, 2026
@JarryShaw
JarryShaw merged commit cc08435 into main Oct 10, 2026
40 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 10, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix)

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

refactor: move shared helper functions into utilities or corekit by use case

1 participant