Skip to content

refactor(corekit)!: move decorators into corekit (#1735) - #1737

Merged
JarryShaw merged 1 commit into
mainfrom
refactor/1735-decorators-into-corekit
Oct 14, 2026
Merged

JarryShaw merged 1 commit into
mainfrom
refactor/1735-decorators-into-corekit

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

Closes #1735. This applies option A from #1712: utilities holds services that import nothing from pcapkit outside utilities. It follows the no-re-export rule from #1715.

  • Move. pcapkit/utilities/decorators.py is now pcapkit/corekit/decorators.py. protocol.py, internet.py, ipv6.py and schema.py import from the new path, and so do the docs, tests and examples.
  • Breaking.
    • Importing pcapkit.utilities.decorators now raises ModuleNotFoundError.
    • seekset, beholder and prepare are no longer available from pcapkit.utilities.
    • The logger is now named pcapkit.corekit.decorators.
  • Rule. A new conventions page, utilities-or-corekit, states the rule. tests/project/test_utilities_import_boundary_1735_unit.py parses every module under pcapkit/utilities/ and fails on any import from elsewhere in pcapkit, whether at top level, inside a function or under TYPE_CHECKING.
  • Tests.

seekset, beholder and prepare act on a protocol's file and schema, and
beholder imports protocol classes, so #1712's option A rules them out of
pcapkit.utilities.

- corekit: git mv pcapkit/utilities/decorators.py to
  pcapkit/corekit/decorators.py. Its top-level imports are only
  utilities.exceptions and utilities.logging, so no cycle. Not added to
  corekit's __init__: the public-API guard skips submodules.
- utilities: no re-export. pcapkit.utilities.decorators now raises
  ModuleNotFoundError, seekset/beholder/prepare leave utilities.__all__
  and all.py's exclusions, and the logger is pcapkit.corekit.decorators.
- importers: protocol.py, internet.py, ipv6.py and schema.py import from
  corekit; every docstring, test and example reference follows.
- docs: the page moves to corekit/decorators.rst with a migration note;
  the rule goes on a new conventions page, utilities-or-corekit.
- tests: test_decorators.py moves to tests/corekit; a project guard parses
  every module under pcapkit/utilities/ and fails on any pcapkit import
  outside it, at top level, in a function or under TYPE_CHECKING; an
  old-path test pins the move.

New tests fail on origin/main; touched suites pass on 3.8, 3.10, 3.11
and 3.14; Sphinx warnings unchanged at 63.

Closes #1735
@JarryShaw JarryShaw added breaking Breaks public-facing behaviour or API (apply alongside the type label) refactor Restructuring for its own sake — neither a fix nor a new capability (refactor: prefix) labels Oct 14, 2026
@JarryShaw

Copy link
Copy Markdown
Owner Author

Verdict: GOOD TO GO at 8cd589ed2. A Sonnet cross-review checked it (author: Opus).

  • No reference to the old path remains outside the migration note and the two new tests. utilities/__init__.py re-exports nothing.
  • Imports have no cycle: I imported 14 modules first in fresh interpreters, 28 runs across 3.14 and 3.8.
  • The guard fails on origin/main at exactly decorators.py:28,29,130,132. A module I planted under pcapkit/utilities/ was flagged for a TYPE_CHECKING import, a function-level import, a relative import, and an importlib literal.
  • Sphinx shows 63 warnings on both trees, and the two warning sets are identical.
  • My own re-run, in the PR's tree: 44 passed, 476 subtests passed across the two new tests, test_decorators, test_public_api and test_all_exports_unit.
  • Non-blocking: one line on the new conventions page is not wrapped to match its neighbours, and the toctree order differs from the preamble's.

@JarryShaw JarryShaw added the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 14, 2026
@JarryShaw JarryShaw moved this to In review in PyPCAPKit Oct 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Coverage: 89.65% (unit tier, Python 3.15, 8cd589ed2, Unit Tests run success)

Package Statements Missed Branches Partial Cover
pcapkit (top level) 104 3 20 3 95.16%
pcapkit/const 18860 954 2368 868 91.06%
pcapkit/corekit 2455 69 780 35 96.54%
pcapkit/dumpkit 275 3 100 3 98.40%
pcapkit/foundation 2885 144 1010 34 94.20%
pcapkit/interface 138 7 52 5 93.68%
pcapkit/protocols 17172 225 4588 189 98.08%
pcapkit/toolkit 1015 173 372 10 80.89%
pcapkit/utilities 436 2 140 4 98.96%
pcapkit/vendor 4417 2342 1010 157 43.38%

Per-file detail: the coverage-html artifact of this run.

@JarryShaw
JarryShaw merged commit 34a197d into main Oct 14, 2026
55 checks passed
@github-project-automation github-project-automation Bot moved this from In review to Done in PyPCAPKit Oct 14, 2026
@JarryShaw JarryShaw removed the review: good-to-go Cross-review at the current head says ready; CI state is separate label Oct 14, 2026
@JarryShaw JarryShaw added this to the PyPCAPKit v1.5 milestone Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaks public-facing behaviour or API (apply alongside the type label) 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(corekit)!: move utilities.decorators into corekit, and state the corekit/utilities rule (#1712, option A)

1 participant