Repository navigation
refactor(utilities): move the ContextVars shared across modules into pcapkit.utilities.contextvars - #2623
Merged
Conversation
…xtvars (#2616) - pcapkit/utilities/contextvars.py: a leaf module holding beholding, frame_depth, in_fragment and rebuilding, public and in __all__. It imports nothing from pcapkit. - Their private definitions leave corekit.checksum.internet, corekit.decorators and protocols.protocol with no re-export; every reader imports them from utilities.contextvars. Module-private ContextVars stay put. - tests/project/test_shared_contextvars_2616_unit.py fails on a ContextVar taken across modules from anywhere else, and on a shared one that is private, missing from __all__ or read by one module alone. - Docs: an API page in the utilities toctree, and a Context Variables section on utilities-or-corekit.rst.
Owner
Author
|
GOOD TO GO at
|
JarryShaw
added a commit
that referenced
this pull request
Nov 2, 2026
… kinds into 1.6.0 (#2449) - Added: pad_length and PaddingField's align/after form (#2624), and pcapkit.utilities.contextvars (#2623); the old private names get no entry, as for the other private API. - Changed: the weekly Issue and PR Kinds workflow, beside the milestone workflow's entry (#2626). - The conventions entry records where a context variable lives (#2623), and the role-kind citation rule with its test (#2626). - No entry for #2626's heading and Mermaid fixes, #2564 or fa9af52. - CHANGELOG.md regenerated; util/changelog_md.py --check passes.
1 of 5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 of your pull request and other information
The ContextVars that more than one module reads now live in a new leaf module,
pcapkit.utilities.contextvars. They arebeholding,frame_depth,in_fragmentandrebuilding, under public names in__all__, with no re-export at their old paths. The module-private ones stay with their owners. This is the owner's option 2 on #2616. The names were underscore-private and absent from every__all__, so nothing public breaks.tests/project/test_shared_contextvars_2616_unit.pyfails when a module takes a ContextVar from anywhere else: top-level, function-local,TYPE_CHECKING, relative or attribute imports, or a re-export by import. It also fails when the shared module holds a variable with fewer than two readers. utilities-or-corekit.rst records where a ContextVar lives. Both import-boundary tests pass.A Sonnet cross-review returned GOOD TO GO. It ran 20 guard mutations and checked every set/reset pair. Semantics are unchanged.
Closes #2616