You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(registry): split foundation.registry.protocols into registry.protocols.<layer> submodules #2578
From the owner on #2511: consider splitting pcapkit/foundation/registry/protocols.py, which holds 56 register_* wrappers, the shared validators (_check_code, _register_name, _NameLease, _MISSING) and register_protocol/register_protocol_code. Name any submodules registry.protocols.<submodule>, following pcapkit.protocols.
Decision needed:
Granularity. (a) Per layer: registry/protocols/{link,internet,transport,application,misc}.py, mirroring pcapkit.protocols' layer subpackages. (b) Per protocol: one module per owning class, roughly 40 small files. (c) Leave the file whole.
Shared helpers. (a) A base module, registry/protocols/protocol.py, after pcapkit.protocols.protocol's framework base, holding the validators plus register_protocol and register_protocol_code. (b) A private _common.py.
Public paths. The package __init__ aggregates its submodules (refactor!: remove every surviving re-export of a moved name or module #1744 D3), so pcapkit.foundation.registry.protocols.register_tcp and pcapkit.foundation.registry.register_tcp keep resolving. The definitions move, so __module__ and the docs' cross-reference targets change.
Recommendation: 1(a), 2(a), 3 as stated. Per-layer files are a size a reader can scan. Per-protocol files would mostly hold one function each, and #2534's per-protocol packages could absorb them later if wanted.
Timing: one mechanical move with no behaviour change, after #2527 and #2544 merge, since both edit this file.
Owner took all three recommendations, paraphrased:
Per layer:pcapkit/foundation/registry/protocols/ becomes a package with link.py, internet.py, transport.py, application.py and misc.py.
Shared helpers: they go in a base module, registry/protocols/protocol.py, after pcapkit.protocols.protocol. That covers _check_code, _register_name, _NameLease, _MISSING, register_protocol and register_protocol_code.
#2527 and #2544 have merged, but several branches add wrappers to registry/protocols.py: #2575, #2533, #2489, #2514 and #2555. A package split now would conflict with every one of them. Blocked: this unblocks when those five PRs merge.
Activity
JarryShaw commentedon Nov 1, 2026
Take all recommendations
JarryShaw commentedon Nov 1, 2026
Owner took all three recommendations, paraphrased:
pcapkit/foundation/registry/protocols/becomes a package withlink.py,internet.py,transport.py,application.pyandmisc.py.registry/protocols/protocol.py, afterpcapkit.protocols.protocol. That covers_check_code,_register_name,_NameLease,_MISSING,register_protocolandregister_protocol_code.__init__aggregates its submodules (refactor!: remove every surviving re-export of a moved name or module #1744 D3).It is one mechanical move with no behaviour change. Blocked: #2527 and #2544 both edit this file, so this unblocks when both merge.
JarryShaw commentedon Nov 1, 2026
#2527 and #2544 have merged, but several branches add wrappers to
registry/protocols.py: #2575, #2533, #2489, #2514 and #2555. A package split now would conflict with every one of them. Blocked: this unblocks when those five PRs merge.