MAINT: Defining pyrit.models boundary#1771
Open
rlundeen2 wants to merge 4 commits into
Open
Conversation
- Add tests/unit/models/test_import_boundary.py: AST-based ratchet that
enforces the pyrit.models -> {stdlib, pydantic, pyrit.common.deprecation,
pyrit.models.*} import rule. Known transitional violations are listed
with phase tags so they shrink monotonically as later phases land.
- Extend pyrit/common/deprecation.py with deprecated_kwarg (for Pydantic
model_validator(mode=before) kwarg promotion) and module_deprecation_getattr
(for module-level __getattr__ deprecation shims, e.g. pyrit.identifiers
re-export after Phase 2).
- Document the import boundary in style-guide.instructions.md and the
pyrit.models package docstring.
No production model code changed in this phase.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Per review feedback: scope the rule to pyrit/models/** via applyTo so it only loads when models code is in scope, instead of being a subsection of the global style guide. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Per review feedback: reuse the existing helper instead of duplicating the warnings.warn call. Same message format; tests unchanged. Note: deprecated_kwarg keeps its inline warnings.warn because its message format intentionally differs (it mentions the kwarg name and model name, not the qualified callable path). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Per review feedback: there's nothing special about seeds — it's just another
part of pyrit.models that has not been migrated yet. Treat its existing
cross-package imports the same way as everything else: list them in
KNOWN_TOP_LEVEL_VIOLATIONS with a phase tag ("seeds-followup") and let the
ratchet shrink them as the work lands.
- _scan_files() now uses rglob so seeds/*.py are scanned.
- _module_name_for() handles nested paths.
- test_seeds_excluded removed; seed.py / seed_dataset.py added to the
scan sanity check.
- Removed the "excluding seeds" carve-out from the instructions file
and the pyrit.models package docstring.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Adding guardrails to
pyrit.modelsand deprecation helpers to help in migrating pyrit.models to only include very slim models.Contributors: see
pyrit.shareddesign for more context [phase 0]