MAINT Enable ruff rule E (pycodestyle errors)#1413
Open
romanlutz wants to merge 1 commit intoAzure:mainfrom
Open
MAINT Enable ruff rule E (pycodestyle errors)#1413romanlutz wants to merge 1 commit intoAzure:mainfrom
romanlutz wants to merge 1 commit intoAzure:mainfrom
Conversation
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>
af54821 to
f59ea43
Compare
Contributor
There was a problem hiding this comment.
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 annotationsafter 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
==toisin 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 |
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.
Enable the E rule category covering: