MAINT: Convert leaf model types to Pydanticv2#1769
Merged
rlundeen2 merged 3 commits intoMay 27, 2026
Conversation
Convert leaf modules in pyrit.models to Pydantic v2 BaseModel in place: - retry_event.RetryEvent - conversation_reference.ConversationReference (frozen, hash by conversation_id) - conversation_stats.ConversationStats (frozen, PREVIEW_MAX_LEN ClassVar) - harm_definition.HarmDefinition / ScaleDescription - json_response_config._JsonResponseConfig RetryEvent and ConversationReference keep deprecated to_dict / from_dict thin wrappers that emit a DeprecationWarning via pyrit.common.deprecation (removed_in=0.16.0). All in-repo callers migrated to model_dump(mode=\"json\") / model_validate (pyrit.models.attack_result, pyrit.memory.memory_models). Verified via repo-wide grep that no internal call sites remain outside the explicit deprecation-coverage tests. No public API breaks: existing import paths and kwarg-only construction preserved. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
adrian-gavrila
approved these changes
May 22, 2026
Contributor
adrian-gavrila
left a comment
There was a problem hiding this comment.
LGTM, left one small comment but it is certainly not blocking.
…chema clash Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
romanlutz
added a commit
to romanlutz/PyRIT
that referenced
this pull request
May 28, 2026
…icks The `check-no-rest-roles` pre-commit hook added in microsoft#1823 flags four `:meth:model_dump` / `:meth:model_validate` references in `pyrit/models/conversation_reference.py` and `pyrit/models/retry_event.py` that landed via PR microsoft#1769 before the hook existed. Replace them with plain double-backticks so the hook passes cleanly on this stacked branch and the deprecation notices render as readable code spans under MyST instead of literal `:meth: ame` text. `model_dump` / `model_validate` are Pydantic methods, not PyRIT API, so the auto-linker leaves them as plain code spans (correct: there is nothing in our docs to link them to). 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.
Converts the leaf modules in
pyrit/models/topydantic.BaseModelin place, with no file moves and no public API breaks.Contributors: see
pyrit.shareddesign for more context [phase 1]