refactor(protocols): import ProtocolBase under its own name in the last 54 sites - #752
Conversation
…st 54 sites Completes #514 part (c). #750 renamed 28 of 82 `ProtocolBase as Protocol` alias imports and deferred the remaining 54 -- all `ProtocolBase` -- to paths #726 and #742 owned. Both have merged, so the deferral is over. * renamed the alias import at all 54 sites (51 under pcapkit/protocols/, 3 under pcapkit/foundation/) and every in-file reference that used the local alias: class headers, annotations, cast(), isinstance/issubclass checks, # type: comments, and the bracketed part of a handful of Sphinx #: doc comments -- 191 lines changed, no statements added * merged two now-unaliased same-module imports per isort in 4 files (application.py, internet.py, link.py, transport.py), removing 4 statements * left descriptive prose, protocol-name string literals, error-message text, and fully-qualified :class:/:meth:/:rtype: cross-references to the real public Protocol class untouched, matching #750's own precedent * emptied tests/test_base_class_contract.py's PENDING_ALIAS_PATHS, its documented end state, and updated the stale docstring narrative No behaviour change: __mro__/__bases__/__module__ identical across 18 classes spanning every family, __proto__ registry 38 keys before and after, descendants(Protocol) 0 in both. mypy stays at the 112-error baseline.
|
✅ GOOD TO MERGE @ Independent cross-review on a different model (opus); first review on this PR. Every claim re-derived myself in a worktree pair,
The test gap, and it is closed. " Widened scope (
Also, not blocking: ✅ GOOD TO MERGE @ |
|
✅ GOOD TO MERGE @ |
|
We explicitly stated in the design that we would deliberately like to check for |
|
That design intent is not implemented today, and was not before this PR either — the alias was hiding
The gap itself is real and worth its own change: if a custom class should be required to subclass Worth recording, because it strengthens the case for the rename: Shall I file the custom-versus-builtin check as its own issue? It is #514's design intent, it is |
|
Recorded: no issue filed — the custom-versus-builtin check is not wanted. So the widened That leaves this PR purely a naming correction with nothing deferred behind it: 6 sites read Worth leaving on the record for the next reader of those six sites, since it is the question that will #752 remains ✅ |
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
Fixes #514.
#750 renamed 28 of the 82
ProtocolBase as Protocolalias imports and deferredthe remaining 54 (all
ProtocolBase, underpcapkit/protocols/and threepcapkit/foundation/modules) to paths #726 and #742 owned. Both have merged,so this completes the rename.
Renamed the alias import at all 54 sites plus every in-file reference that
used the local alias -- class headers, annotations,
cast(),isinstance/issubclasschecks,# type:comments, and the bracketed partof a handful of Sphinx
#:doc comments. Left descriptive prose, protocolname string literals, error-message text, and fully-qualified
:class:/:meth:/:rtype:cross-references to the real publicProtocolclass untouched, matching #750's own precedent. Four files
(
application.py,internet.py,link.py,transport.py) needed their twonow-unaliased same-module imports merged per isort. Emptied
tests/test_base_class_contract.py'sPENDING_ALIAS_PATHS-- its documentedend state -- and updated the now-stale docstring narrative.
Verification:
__mro__/__bases__/__module__identical across 18classes spanning every touched family;
pcapkit.protocols.__proto__38 keysbefore and after;
descendants(Protocol)0 in bothtest_base_class_contract.py's two alias tests fail onorigin/mainwithPENDING_ALIAS_PATHSemptied, pass with this rename(
python -m unittest, andcoverage run -m pytest, not pytest-cov)make test, which is forbidden here):tests/test_base_class_contract.py,tests/protocols/(by subdirectory),tests/foundation/registry/test_protocols.py,tests/foundation/test_extraction*.py,tests/foundation/traceflow/--746 tests / 2995 subtests, all passing, run in memory-bounded batches
No
breakinglabel: the produced class objects are identical to before (seeclass-identity proof above), so no correct caller code changes behaviour.