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(corekit): move pcapkit.utilities.chardet into corekit #1712
Describe the bug pcapkit.utilities.chardet (detect, the bounded-cache wrapper around chardet) is used by corekit/fields/strings.py:8, protocols/protocol.py:48, protocols/application/ftp.py:29 and httpv1.py:44, and is re-exported from pcapkit/utilities/__init__.py:15. The owner wants it in pcapkit.corekit.
Expected behavior
The module moves under pcapkit.corekit and its importers follow.
pcapkit.utilities.chardet and the pcapkit.utilities.detect re-export stay importable, so the move is not a breaking change.
docs/source/pcapkit/utilities/chardet.rst moves to the corekit docs.
Blocked until #1707 and #1706 merge, since both edit corekit/fields/strings.py.
#1707 has merged. A worker is on it, with no re-export at the old path (the ruling on #1715). In strings.py it changes only the import line, so it does not collide with #1706.
Understood. I am holding #1729, the chardet move, until the criterion is settled. Next I will post an inventory of every module in pcapkit/corekit and pcapkit/utilities: what each imports from pcapkit, who imports it, and whether it carries packet or protocol knowledge. Each module gets a proposed rule applied to it, so the decision is about concrete moves rather than names.
Inventory of every module in both packages, on main (fb7027b25). The import order today is already utilities (all of it), then corekit, then protocols/const, with one exception.
Proposed rule:
utilities holds cross-cutting services: reporting (exceptions, warnings, logging), configuration, compatibility shims and wrappers around third-party libraries. It imports nothing from pcapkit outside utilities, at top level, inside a function or under TYPE_CHECKING. It carries no wire format or protocol behaviour.
corekit holds the types the packet model is built from: what protocols, const and foundation subclass, instantiate or decorate with. It may import utilities, and reaches protocols only lazily.
Applied, only one module moves:
utilities.decorators breaks the rule.seekset, beholder and prepare act on Protocol._file and _seekset, and beholder lazily imports protocols.misc.null and raw (decorators.py:130-132). It would move to corekit.decorators (or protocols), adding no import-time cycle. That breaks pcapkit.utilities.{seekset,beholder,prepare} and the logger name pcapkit.utilities.decorators.
The alternative, a "no packet knowledge" test, would also move multidict, version, module, sentinels, io, infoclass, enum and packet into utilities. That is about 8 breaking moves, each dragging the others, and leaves corekit with only fields, protochain, context, packet and byteorder.
Your call: which rule? Under the proposed one, should #1729 close (chardet stays put), and where should decorators go, corekit or protocols?
Three options. Each comes down to one question asked of a module.
Option
Question that decides
utilities gets
corekit gets
Breaking moves
A. Services vs types (recommended)
Is it a service any code could use (reporting, config, compat, third-party wrapper) that imports nothing from pcapkit outside utilities? Then utilities; otherwise corekit.
decorators moves under all three. It works on Protocol._file and imports protocol classes, so it fails every utilities test.
The trade-offs:
A: the rule is checkable by import graph alone, since utilities never imports corekit. It also churns least.
B: cleanest by meaning. But the seven modules must move together, because infoclass imports enum and multidict, and enum and module import sentinels. The public types Info, MultiDict, EnumRegistry and VersionInfo would change path.
C: keeps your earlier call that chardet belongs with the fields. Its question is the fuzziest, though: compat and exceptions are also used mostly by the packet model, yet stay put.
Activity
JarryShaw commentedon Oct 14, 2026
The ruling on #1715 applies here too: the move updates every import path directly, with no re-export left at
pcapkit/utilities/chardet.py.JarryShaw commentedon Oct 14, 2026
#1707 has merged. A worker is on it, with no re-export at the old path (the ruling on #1715). In
strings.pyit changes only the import line, so it does not collide with #1706.JarryShaw commentedon Oct 14, 2026
I'm kinda debating what's the criteria for
corekitorutilities. Not sure ifchardetand many other modules undercorekitandutilitiesshould live.JarryShaw commentedon Oct 14, 2026
Understood. I am holding #1729, the chardet move, until the criterion is settled. Next I will post an inventory of every module in
pcapkit/corekitandpcapkit/utilities: what each imports from pcapkit, who imports it, and whether it carries packet or protocol knowledge. Each module gets a proposed rule applied to it, so the decision is about concrete moves rather than names.JarryShaw commentedon Oct 14, 2026
Inventory of every module in both packages, on
main(fb7027b25). The import order today is alreadyutilities(all of it), thencorekit, thenprotocols/const, with one exception.Proposed rule:
utilitiesholds cross-cutting services: reporting (exceptions, warnings, logging), configuration, compatibility shims and wrappers around third-party libraries. It imports nothing from pcapkit outsideutilities, at top level, inside a function or underTYPE_CHECKING. It carries no wire format or protocol behaviour.corekitholds the types the packet model is built from: whatprotocols,constandfoundationsubclass, instantiate or decorate with. It may importutilities, and reachesprotocolsonly lazily.Applied, only one module moves:
utilities.decoratorsbreaks the rule.seekset,beholderandprepareact onProtocol._fileand_seekset, andbeholderlazily importsprotocols.misc.nullandraw(decorators.py:130-132). It would move tocorekit.decorators(orprotocols), adding no import-time cycle. That breakspcapkit.utilities.{seekset,beholder,prepare}and the logger namepcapkit.utilities.decorators.chardetstays inutilities. It is a leaf third-party wrapper that imports onlyfunctoolsandchardet, so refactor(corekit)!: move chardet into corekit (#1712) #1729 goes against this rule. Either rule is cycle-safe for chardet.utilities/config.pyfits: a configuration service that imports onlyutilities.warnings.The alternative, a "no packet knowledge" test, would also move
multidict,version,module,sentinels,io,infoclass,enumandpacketintoutilities. That is about 8 breaking moves, each dragging the others, and leavescorekitwith onlyfields,protochain,context,packetandbyteorder.Your call: which rule? Under the proposed one, should #1729 close (chardet stays put), and where should
decoratorsgo,corekitorprotocols?JarryShaw commentedon Oct 14, 2026
explain better about the options and criteria for the split of each option
JarryShaw commentedon Oct 14, 2026
Three options. Each comes down to one question asked of a module.
utilitiesgetscorekitgetsutilities? Thenutilities; otherwisecorekit.corekit, no meansutilities.corekit.decoratorsmoves under all three. It works onProtocol._fileand imports protocol classes, so it fails everyutilitiestest.The trade-offs:
utilitiesnever importscorekit. It also churns least.infoclassimportsenumandmultidict, andenumandmoduleimportsentinels. The public typesInfo,MultiDict,EnumRegistryandVersionInfowould change path.compatandexceptionsare also used mostly by the packet model, yet stay put.All three are cycle-safe as moved.
JarryShaw commentedon Oct 14, 2026
okay, i think we should take A
JarryShaw commentedon Oct 14, 2026
Recorded: option A.
utilitiesholds cross-cutting services: exceptions, warnings, logging, compat, config and third-party wrappers. It imports nothing from pcapkit outsideutilities.corekitholds the types the packet model is built from.What this means for the open work:
chardetstays inutilities, so this issue's move is withdrawn and refactor(corekit)!: move chardet into corekit (#1712) #1729 closes unmerged.utilities.decoratorsintocorekit, together with writing the rule into the conventions docs, is tracked in refactor(corekit)!: move utilities.decorators into corekit, and state the corekit/utilities rule (#1712, option A) #1735.refactor(corekit)!: move decorators into corekit (#1735) (#1737)