Repository navigation
[BREAKING] MAINT: Migrate the remaining str enums to StrEnum and enable UP042 (#4508) - #4644
Open
Aditya Malkar (adimalkar) wants to merge 1 commit into
Open
Aditya Malkar (adimalkar) wants to merge 1 commit into
Aditya Malkar (adimalkar) wants to merge 1 commit into
Conversation
…le UP042 PR 3 of microsoft#4508: 67 classes in pyrit/ and one e2e fixture. str(member) and f-strings now give the value instead of Class.MEMBER; values, equality and JSON are unchanged. AttackOutcome keeps a noqa until microsoft#4589 migrates it.
This branch has not been deployed
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.
Description
Moves the remaining
str, Enumclasses toStrEnumand re-enables Ruff'sUP042, which is PR 3 of #4508.pyrit/and one frontend e2e fixture are migrated. Members, values, equality, JSON and the backend's OpenAPI schema are unchanged.UP042is no longer ignored, so newstr, Enumclasses fail pre-commit.AttackOutcomekeeps anoqauntil [BREAKING] MAINT: Migrate AttackOutcome to StrEnum #4589 migrates it.StrEnum, formats as its value and round-trips.StrEnum.The tracker's sweep counted 61 classes and
mainnow has 67, so the batch was rechecked by recording everystr()/format()of these members during a fulltests/unitrun onmain. The only site hit is_coerce_enuminpyrit/models/parameter.py, which returns the same member before and after.Release note.
str(member),f"{member}"and"%s" % membernow give the value (skip) instead ofIncompatibleTechniquePolicy.SKIP. Code that depends on the old text should usetype(member).__name__andmember.name.repr(member)is unchanged. Public exports affected:51 classes
pyrit.analytics:PairedOutcomeTransitionpyrit.converter:PuzzleTypepyrit.executor.attack:SequenceCompletionPolicypyrit.models:Acquisition,AssertPatternRole,AssertReplication,AssertSampleVote,AssertSamplingMethod,AssertSkipReason,AttackAnalyticsConverterDirection,AttackAnalyticsDimensionName,AttackAnalyticsMatchMode,AttackAnalyticsValueKind,AttackResultRole,AttackResultSelection,CapabilityName,DatasetFetchPolicy,DatasetLimitState,DatasetSelectionMode,ExecutionStepKind,Modality,ParameterDestination,PromptGenerationStatus,ScenarioDatasetSizeEstimateKind,ScenarioObjectiveScorerAttribution,ScenarioObjectiveScorerScope,ScenarioRunPlanGroupKind,ScenarioRunSizeEstimateCondition,ScenarioRunSizeEstimateStatus,ScenarioSuiteExecutionStatus,ScenarioSuiteSubmissionState,ScoreStatus,ScorerCapabilityName,ScorerVerdictStatus,SurfaceMatch,ToolCaptureGap,ToolLoopStopReason,TraceSpanStatus,WebSearchModepyrit.models.catalog:RegistryEntryOrigin,RegistryRecipeKind,RestoreFailureReasonpyrit.prompt_target:UnsupportedCapabilityBehaviorpyrit.scenario:IncompatibleTechniquePolicypyrit.scenario.core:ScorerOverridePolicypyrit.score:AssertJudgmentMode,AssertScoringDimension,RobloxPiiCategory,ScorerMismatchKind,TraceEvidenceRequirementpyrit.setup.initializers.techniques:TechniqueInitializerTagsRelates to #4508
AI assistance: Claude Code wrote this change and ran the checks.