Repository navigation
MAINT Migrate ConversationRetryReason to StrEnum (P311-17) - #3850
Merged
Roman Lutz (romanlutz) merged 1 commit intoNov 3, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the focused migration of ConversationRetryReason to StrEnum.
No open issues 🎉
What changed in this PR
Migrates ConversationRetryReason to Python 3.11’s StrEnum as a focused step toward #3166 (P311-17), preserving retry values and JSON serialization.
Changes:
- Replaces the
(str, Enum)base withStrEnum. - Adds tests for string rendering, equality, value lookup, JSON encoding, and Pydantic serialization round trips.
| File | Description |
|---|---|
tests/unit/models/test_conversation_retry.py |
Adds regression coverage for enum behavior and serialization. |
pyrit/models/messages/conversation_retry.py |
Changes ConversationRetryReason to inherit from StrEnum. |
Review effort: Balanced
Roman Lutz (romanlutz)
self-requested a review
November 3, 2026 07:26
19 of 25 tasks
Roman Lutz (romanlutz)
approved these changes
Nov 3, 2026
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.
Part of #3166 (P311-17: assess
enum.StrEnum). PyRIT requires Python >= 3.11, soenum.StrEnumis available.This migrates one enum,
ConversationRetryReason, from(str, Enum)toStrEnum. It was chosen because no code path relies onstr()/format()producing the class-qualified form. Persistence goes throughConversationRetry.model_dump(mode="json"), which already stores the value, and comparisons use members or plain-string equality, which behave the same under both bases.The only observable change is that
str(member)andformat(member)now return"json_parsing"instead of"ConversationRetryReason.JSON_PARSING".Tests: added
tests/unit/models/test_conversation_retry.py, which pinsstr(), f-string andformat()output, string equality, value lookup,json.dumps, and the pydantic JSON round trip. Existing retry, memory and crescendo-resume tests pass;ty, pre-commit and the unit suite pass locally.The other
(str, Enum)classes inpyrit/could follow the same way, one by one, after checking each for uses of the qualifiedstr()form.This PR was prepared with AI assistance and reviewed by me.