Skip to content

MAINT Return Self from AdversarialPrompts.from_metadata (P311-01) - #3779

Merged
Roman Lutz (romanlutz) merged 1 commit into
microsoft:mainfrom
juliosuas:feat/p311-01-adversarial-prompts-from-metadata
Nov 2, 2026
Merged

Roman Lutz (romanlutz) merged 1 commit into
microsoft:mainfrom
juliosuas:feat/p311-01-adversarial-prompts-from-metadata

Conversation

@juliosuas

Copy link
Copy Markdown
Contributor

Description

Claimed and assigned as item P311-01 in #3166. This is the focused AdversarialPrompts.from_metadata follow-up and mirrors #3626 (WebSearchConfig.from_metadata).

  • AdversarialPrompts.from_metadata now returns Self | None instead of AdversarialPrompts | None, so subclasses get their own type back.
  • Runtime behavior is unchanged: absent associations still return None, inputs are read-only Mappings and are not mutated, and validation is unchanged.

Tests and Documentation

Added TestAdversarialPromptsFromMetadata in tests/unit/models/test_adversarial_prompts.py:

  • absent association (None, {}, unrelated keys) returns None for the base class and a subclass
  • present association returns the calling class (assert_type plus runtime type(...) is checks)
  • JSON metadata round trip, read-only MappingProxyType input, no mutation
  • invalid payloads raise ValidationError

Ran locally:

  • pytest -n 4 --dist=loadfile tests/unit: 32991 passed, 32 skipped
  • ty check pyrit tests/unit (make ty): all checks passed
  • pre-commit run --all-files: passed

No documentation changes needed; JupyText not applicable.

@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Nov 2, 2026
Merged via the queue into microsoft:main with commit 3e96e9a Nov 2, 2026
65 of 66 checks passed
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.

2 participants