Skip to content

MAINT: add _async suffix to async helpers in pyrit/common#1744

Merged
romanlutz merged 5 commits into
microsoft:mainfrom
romanlutz:romanlutz/async-suffix-renames
May 20, 2026
Merged

MAINT: add _async suffix to async helpers in pyrit/common#1744
romanlutz merged 5 commits into
microsoft:mainfrom
romanlutz:romanlutz/async-suffix-renames

Conversation

@romanlutz
Copy link
Copy Markdown
Contributor

Description

The PyRIT style guide mandates that every async def function end with the _async suffix, but several helpers in pyrit/common/ were missing it. This PR renames those helpers, keeps the old names as thin deprecation wrappers (removed in v0.16.0), and updates the internal call sites and test patches accordingly.

Renames (with deprecation wrappers that delegate and emit DeprecationWarning):

  • pyrit/common/data_url_converter.py: convert_local_image_to_data_url -> ..._async
  • pyrit/common/display_response.py: display_image_response -> ..._async
  • pyrit/common/download_hf_model.py: download_specific_files, download_chunk, download_file, download_files -> all ..._async

The nested local helper download_with_limit inside download_files_async is also renamed to download_with_limit_async in place (not importable, so no deprecation needed).

Internal callers updated:

  • pyrit/prompt_target/openai/openai_chat_target.py
  • pyrit/prompt_target/openai/openai_response_target.py
  • pyrit/prompt_target/websocket_copilot_target.py
  • pyrit/prompt_target/hugging_face/hugging_face_chat_target.py
  • pyrit/message_normalizer/chat_message_normalizer.py
  • pyrit/executor/attack/printer/console_printer.py

Tests and Documentation

  • Updated all affected test imports and mock.patch targets to the new names.
  • Added a pytest.warns(DeprecationWarning, ...) test for each module-level wrapper (convert_local_image_to_data_url, display_image_response, download_specific_files) so the deprecation path is exercised before removal.
  • uv run pytest over the affected test modules: 290 passed, 28 skipped (skips are pre-existing torch-not-installed guards).
  • uv run ruff check and uv run ruff format --check clean on all modified files.
  • ty type check (pre-commit) passed on commit.
  • No documentation references to the renamed functions exist under doc/, so no notebook/JupyText updates were needed.

romanlutz and others added 4 commits May 18, 2026 05:29
Renames the following async helpers to comply with the PyRIT style guide
requirement that all async functions end with _async. Old names are kept
as thin deprecation wrappers that delegate to the new names and emit
DeprecationWarning. They will be removed in v0.16.0.

- convert_local_image_to_data_url -> convert_local_image_to_data_url_async
- display_image_response -> display_image_response_async
- download_specific_files -> download_specific_files_async
- download_chunk -> download_chunk_async
- download_file -> download_file_async
- download_files -> download_files_async
- download_with_limit -> download_with_limit_async (nested helper, renamed in place)

Updates all internal call sites and test patches to use the new names,
and adds deprecation-warning tests for each module-level wrapper.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…anch

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…x-renames

# Conflicts:
#	pyrit/executor/attack/printer/console_printer.py
#	tests/unit/executor/attack/printer/test_console_printer.py
@hannahwestra25 hannahwestra25 self-assigned this May 19, 2026
Comment thread pyrit/common/data_url_converter.py Outdated
Comment thread pyrit/common/display_response.py Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@romanlutz romanlutz added this pull request to the merge queue May 20, 2026
Merged via the queue into microsoft:main with commit ce48abc May 20, 2026
48 checks passed
@romanlutz romanlutz deleted the romanlutz/async-suffix-renames branch May 20, 2026 17:35
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