Skip to content

MAINT: Fix ty unsound-assignment findings (UA-3) - #4520

Merged
Roman Lutz (romanlutz) merged 7 commits into
microsoft:mainfrom
clossal:investigate/4402-ua3
Nov 22, 2026
Merged

Roman Lutz (romanlutz) merged 7 commits into
microsoft:mainfrom
clossal:investigate/4402-ua3

Conversation

@clossal

Copy link
Copy Markdown
Contributor

Summary

Relates to #4402 (UA-3).

  • Fix ty unsound-assignment findings across pyrit/prompt_target, pyrit/embedding, and pyrit/auth.
  • Add runtime type validation where required.
  • Preserve parameter and return types in pyrit_target_retry to resolve an OpenAI Response target typing error.
  • Remove the seven resolved UA-3 paths from the temporary ty overrides in pyproject.toml.

Validation

  • ty 0.0.99: No remaining unsound-assignment diagnostics in the assigned directories.
  • Focused type checks for the OpenAI Response target and retry decorator passed.
  • 97 relevant unit tests passed.
  • git diff --check passed.

The broader type check still reports diagnostics associated with unavailable optional dependencies (a2a, copilot, and litellm).

Scope

The shared retry decorator typing change is included because its previous Callable[..., Any] signature erased the return type of the decorated OpenAI Response target method.

The separately identified Prompt Shield response-count validation issue is not included in this PR.

Copilot AI balanced review requested due to automatic review settings November 21, 2026 11:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues remain for the typing and runtime-validation changes.

No open issues 🎉

What changed in this PR

Advances UA-3 of #4402 by resolving ty unsound-assignment findings in authentication, embeddings, and prompt targets, allowing seven files to leave the temporary override list.

Changes:

  • Adds runtime validation for embedding settings, Azure SAS tokens, and OpenAI error payloads, with focused unit tests.
  • Preserves decorated function signatures in pyrit_target_retry and tightens local typing.
  • Removes the seven resolved paths from the temporary type-checking exemptions.
File Description
tests/​unit/​prompt_target/​target/​test_prompt_target_azure_blob_storage.py Tests rejection of non-string SAS tokens.
tests/​unit/​prompt_target/​target/​test_openai_error_handling.py Tests dictionary key validation and clarifies a test docstring.
tests/​unit/​embedding/​test_azure_text_embedding.py Tests rejection of non-string endpoints and model names.
pyrit/​prompt_target/​prompt_shield_target.py Uses object annotations for values checked only for truthiness.
pyrit/​prompt_target/​openai/​openai_response_target.py Separates the extra-tools variable from existing typed state.
pyrit/​prompt_target/​openai/​openai_error_handling.py Validates string-keyed error payload dictionaries.
pyrit/​prompt_target/​common/​discover_target_capabilities.py Uses floating-point exponentiation for retry backoff.
pyrit/​prompt_target/​azure_blob_storage_target.py Validates the resolved SAS token type.
pyrit/​exceptions/​exception_classes.py Preserves retry-decorated parameter and return types.
pyrit/​embedding/​openai_text_embedding.py Validates resolved endpoint and model-name types.
pyrit/​auth/​browser_session_copilot_authenticator.py Explicitly types the token future with a justified cast.
pyproject.toml Removes seven resolved unsound-assignment exemptions.

Review effort: Balanced

@romanlutz
Roman Lutz (romanlutz) added this pull request to the merge queue Nov 22, 2026
Merged via the queue into microsoft:main with commit 1c3cb19 Nov 22, 2026
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.

3 participants