Skip to content

MAINT Enable ruff rule E (pycodestyle errors)#1413

Open
romanlutz wants to merge 1 commit intoAzure:mainfrom
romanlutz:romanlutz/ruff_e
Open

MAINT Enable ruff rule E (pycodestyle errors)#1413
romanlutz wants to merge 1 commit intoAzure:mainfrom
romanlutz:romanlutz/ruff_e

Conversation

@romanlutz
Copy link
Contributor

Enable the E rule category covering:

  • E402: module import not at top of file (fixed docstring placement, noqa for intentional)
  • E501: line too long (wrapped long strings/docstrings to 120 chars)
  • E721: type comparison (use 'is' instead of '==')
  • E731: lambda assignment (converted to def)

Copilot AI review requested due to automatic review settings February 27, 2026 17:51
Enable the E rule category covering:
- E402: module import not at top of file (fixed docstring placement, noqa for intentional)
- E501: line too long (wrapped long strings/docstrings to 120 chars)
- E721: type comparison (use 'is' instead of '==')
- E731: lambda assignment (converted to def)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This maintenance PR enables the ruff E rule category (pycodestyle errors) in the linting configuration to enforce code style consistency across the PyRIT codebase. The changes address four specific error types: E402 (module imports not at top of file), E501 (lines exceeding 120 characters), E721 (type comparisons using == instead of is), and E731 (lambda assignments instead of def statements).

Changes:

  • Enabled ruff E rule in pyproject.toml to enforce pycodestyle error checks
  • Fixed import placement in 3 files (moved from __future__ import annotations after module docstrings, added noqa comment where intentional)
  • Wrapped long strings and docstrings to comply with 120-character line limit in 11 files
  • Changed type comparison from == to is in test file
  • Converted lambda assignment to proper function definition in discovery module

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pyproject.toml Enabled ruff E rule category in linting configuration
pyrit/scenario/core/scenario_strategy.py Moved from __future__ import annotations after module docstring
pyrit/backend/mappers/attack_mappers.py Moved from __future__ import annotations after module docstring
pyrit/cli/pyrit_backend.py Added noqa:E402 comment for intentional import after sys.stdout.reconfigure
tests/unit/score/test_scorer_prompt_validator.py Shortened docstring to fit 120-character limit
pyrit/score/scorer_evaluation/scorer_metrics_io.py Split long logger.info string across two lines
pyrit/score/audio_transcript_scorer.py Split long logger.info string across two lines
pyrit/scenario/scenarios/airt/jailbreak.py Split long ValueError message across two lines
pyrit/prompt_target/openai/openai_target.py Split long logger.info string across two lines
pyrit/prompt_target/openai/openai_image_target.py Reformatted image_size docstring parameter across multiple lines
pyrit/executor/attack/multi_turn/chunked_request.py Split long request_template docstring across two lines
pyrit/datasets/seed_datasets/remote/vlsu_multimodal_dataset.py Split long User-Agent string across multiple lines using tuple concatenation
pyrit/datasets/jailbreak/text_jailbreak.py Split long ValueError message across two lines
pyrit/cli/pyrit_shell.py Wrapped multiple long strings and command examples with backslash continuations
pyrit/backend/routes/attacks.py Split long Query parameter description across multiple lines
tests/unit/executor/attack/multi_turn/test_red_teaming.py Changed type comparison from == str to is str
pyrit/registry/discovery.py Converted lambda assignment to proper function definition with type hints

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