Skip to content

MAINT: Defining pyrit.models boundary#1771

Open
rlundeen2 wants to merge 4 commits into
microsoft:mainfrom
rlundeen2:rlundeen2/models-pydantic-phase-0
Open

MAINT: Defining pyrit.models boundary#1771
rlundeen2 wants to merge 4 commits into
microsoft:mainfrom
rlundeen2:rlundeen2/models-pydantic-phase-0

Conversation

@rlundeen2
Copy link
Copy Markdown
Contributor

Adding guardrails to pyrit.models and deprecation helpers to help in migrating pyrit.models to only include very slim models.

Contributors: see pyrit.shared design for more context [phase 0]

rlundeen2 and others added 4 commits May 20, 2026 17:36
- 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>
@romanlutz romanlutz changed the title MAINT: Defining pyrit.models boundry MAINT: Defining pyrit.models boundary May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant