Skip to content

[STYLE]: Fixup Linting of Initial Files - #7

Merged
Spencer Schoenberg (spencrr) merged 5 commits into
mainfrom
spencrr/lint-project-files
Apr 15, 2026
Merged

[STYLE]: Fixup Linting of Initial Files#7
Spencer Schoenberg (spencrr) merged 5 commits into
mainfrom
spencrr/lint-project-files

Conversation

@spencrr

@spencrr Spencer Schoenberg (spencrr) commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Description

Sets up ruff config and fixes existing project files

See fixes
fix: resolve all 189 ruff lint violations

Per-file-ignores for tests/ (pyproject.toml):
  S101, D100-D107, ANN001/ANN201/ANN202, PLR2004, ARG001/ARG002,
  PLC0415, SLF001, TRY003/EM101/EM102, BLE001, TRY301, S108,
  PT017/PT018, ASYNC240, PERF401, RUF015, PTH123

TC001/TC002/TC003 (45 fixes) - moved type-only imports into TYPE_CHECKING blocks:
  rampart/attacks/__init__.py, rampart/core/adapter.py,
  rampart/core/converter.py, rampart/core/execution.py,
  rampart/core/injection.py, rampart/core/prompt_driver.py,
  rampart/core/types.py, rampart/payloads/__init__.py,
  rampart/payloads/_generator.py, rampart/probes/__init__.py,
  rampart/probes/_single_turn.py, rampart/pytest_plugin/_collection.py,
  rampart/pytest_plugin/_session.py, rampart/pytest_plugin/plugin.py,
  rampart/reporting/json_file.py, rampart/surfaces/onedrive.py,
  rampart/_pyrit/llm_bridge.py, rampart/evaluators/response_contains.py,
  tests/fixtures.py

TRY003/EM101/EM102 (50 fixes) - extracted exception messages to msg variable:
  rampart/_pyrit/llm_bridge.py:86-91, rampart/converters/docx.py:63-64,
  rampart/core/execution.py:146-148, rampart/core/types.py:119-131,217-218,300,
  rampart/drivers/__init__.py:37-39, rampart/payloads/__init__.py:144,
  rampart/payloads/_store.py:82,135-138,191-192,201-202,350,
  rampart/probes/__init__.py:87-88, rampart/pytest_plugin/_session.py:104-106,
  rampart/pytest_plugin/plugin.py:111-116,200-201,
  rampart/surfaces/onedrive.py:95-97,104-107,119-121,180-182

PYI034 (9 fixes) - changed __aenter__ return type to Self:
  rampart/core/adapter.py:42, rampart/core/injection.py:41,
  rampart/surfaces/onedrive.py:171, tests/fixtures.py:43,
  tests/unit/core/test_execution.py:25, tests/unit/core/test_protocols.py:23,43,89,118

PYI036/ANN401 (9 fixes) - changed exc_tb: Any to types.TracebackType | None:
  rampart/core/adapter.py:51, rampart/core/injection.py:50,
  rampart/surfaces/onedrive.py:203, tests/fixtures.py:53,
  tests/unit/core/test_execution.py:33, tests/unit/core/test_protocols.py:30,50,96,125

D107 (8 fixes) - added __init__ docstrings:
  rampart/converters/docx.py:34, rampart/core/execution.py:182,
  rampart/drivers/static.py:25, rampart/evaluators/response_contains.py:23,
  rampart/evaluators/side_effect.py:19, rampart/evaluators/tool_called.py:26,
  rampart/reporting/json_file.py:39, rampart/surfaces/onedrive.py:51

D205 (3 fixes) - inserted blank line after docstring summary:
  rampart/core/execution.py:201, rampart/pytest_plugin/plugin.py:122,
  tests/fixtures.py:57

E501 (10 fixes) - shortened lines exceeding 88 chars:
  rampart/core/execution.py:78, rampart/core/manifest.py:88,97,
  rampart/core/result.py:137, rampart/evaluators/response_contains.py:19,
  rampart/probes/_single_turn.py:104, rampart/pytest_plugin/_session.py:106,
  tests/fixtures.py:86, tests/unit/attacks/test_xpia.py:72,
  tests/unit/core/test_result.py:1

SLF001 (8 fixes) - added public properties to OneDriveSurface (drive_id,
  folder_path, indexing_delay), updated _OneDriveInjection to use them:
  rampart/surfaces/onedrive.py:159,174,181-182,195,200

PLW2901 (2 fixes) - renamed loop variables to avoid reassignment:
  rampart/payloads/_store.py:143-144 (line -> raw_line)
  rampart/pytest_plugin/_session.py:146 (result -> original_result)

PLR2004 (1 fix) - extracted magic value to _PREVIEW_MAX_LENGTH constant:
  rampart/core/types.py:136-137

RUF006 (1 fix) - stored create_task return value:
  rampart/pytest_plugin/plugin.py:523

noqa suppressions introduced (29 total):
  rampart/_pyrit/llm_bridge.py:128,130       PLC0415  deferred pyrit imports
  rampart/converters/docx.py:41              PLC0415  lazy pyrit converter import
  rampart/core/execution.py:314              BLE001   handler safety catch
  rampart/evaluators/side_effect.py:19       ANN401   **kwargs API design
  rampart/evaluators/tool_called.py:26       ANN401   **kwargs API design
  rampart/payloads/__init__.py:92            PLR0913  factory method
  rampart/probes/__init__.py:56              PLR0913  factory method
  rampart/probes/__init__.py:98              S101     type narrowing assert
  rampart/pytest_plugin/plugin.py:223-224    SLF001   pytest item private attrs
  rampart/pytest_plugin/plugin.py:240        ARG001   pytest hook signature
  rampart/pytest_plugin/plugin.py:297        BLE001   plugin safety catch
  rampart/pytest_plugin/plugin.py:458        ARG001   pytest hook signature
  rampart/pytest_plugin/plugin.py:496        BLE001   sink teardown safety
  rampart/pytest_plugin/plugin.py:523        RUF006   fire-and-forget task
  rampart/pytest_plugin/plugin.py:528,559,580 ANN401  no public type for terminalreporter
  rampart/pytest_plugin/plugin.py:581        ARG001   pytest hook signature
  rampart/surfaces/onedrive.py:202           SLF001   inner class -> parent._upload_async
  rampart/surfaces/onedrive.py:226           SLF001   inner class -> parent._delete_async
  rampart/surfaces/onedrive.py:227           BLE001   cleanup must not raise
  tests/unit/pytest_plugin/test_plugin.py:35-51  ANN401 x6  _StashStub dict mock
  tests/unit/surfaces/test_onedrive.py:25    ANN401   sentinel default
  tests/unit/surfaces/test_onedrive.py:63    ANN401   mock dispatch return

Breaking changes

None

Checklist

@spencrr
Spencer Schoenberg (spencrr) changed the base branch from spencrr/init-project-files to main April 9, 2026 22:43
@spencrr
Spencer Schoenberg (spencrr) marked this pull request as ready for review April 9, 2026 22:43
@spencrr
Spencer Schoenberg (spencrr) requested a review from a team April 9, 2026 22:43
@spencrr

Copy link
Copy Markdown
Contributor Author

Note: Please scrutinize any changes made - some were by ruff --fix, some ruff --unsafe-fixes --fix, and some by Copilot 😉

@nina-msft Nina Chikanov (nina-msft) 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.

I went through and spot checked for the changes you listed in the description and doesn't seem like any of them would break functionality to me. The only change block I didn't see changes for was:

SLF001 (8 fixes) - added public properties to OneDriveSurface (drive_id,
  folder_path, indexing_delay), updated _OneDriveInjection to use them:
  rampart/surfaces/onedrive.py:159,174,181-182,195,200

I also don't have context for all of the #noqa additions - were these added by linter? Approving to unblock since I'm out tomorrow but feel free to solicit a second pair of eyes if you'd like!

@spencrr

Copy link
Copy Markdown
Contributor Author

I went through and spot checked for the changes you listed in the description and doesn't seem like any of them would break functionality to me. The only change block I didn't see changes for was:

SLF001 (8 fixes) - added public properties to OneDriveSurface (drive_id,
  folder_path, indexing_delay), updated _OneDriveInjection to use them:
  rampart/surfaces/onedrive.py:159,174,181-182,195,200

I also don't have context for all of the #noqa additions - were these added by linter? Approving to unblock since I'm out tomorrow but feel free to solicit a second pair of eyes if you'd like!

  1. I believe it's this: https://github.com/microsoft/RAMPART/pull/7/changes#diff-854fd89190bdd459d6c98c578ba5099cc343d1e6dac44e2c994ab80722b7bbd2R71-R84 and called from https://github.com/microsoft/RAMPART/pull/7/changes#diff-854fd89190bdd459d6c98c578ba5099cc343d1e6dac44e2c994ab80722b7bbd2R190 and a few other spots
  2. about the noqa's, yeah that would be Copilot's decision - I can re-review myself just to see if there are any that warrant a cleaner solution

Comment thread rampart/surfaces/onedrive.py
Comment thread rampart/surfaces/onedrive.py Outdated
Comment thread tests/unit/evaluators/test_side_effect.py Dismissed
Comment thread tests/unit/evaluators/test_side_effect.py Dismissed
Comment thread rampart/pytest_plugin/plugin.py Fixed
Comment thread tests/unit/core/test_protocols.py Dismissed
fix: resolve all 189 ruff lint violations

Per-file-ignores for tests/ (pyproject.toml):
  S101, D100-D107, ANN001/ANN201/ANN202, PLR2004, ARG001/ARG002,
  PLC0415, SLF001, TRY003/EM101/EM102, BLE001, TRY301, S108,
  PT017/PT018, ASYNC240, PERF401, RUF015, PTH123

TC001/TC002/TC003 (45 fixes) - moved type-only imports into TYPE_CHECKING blocks:
  rampart/attacks/__init__.py, rampart/core/adapter.py,
  rampart/core/converter.py, rampart/core/execution.py,
  rampart/core/injection.py, rampart/core/prompt_driver.py,
  rampart/core/types.py, rampart/payloads/__init__.py,
  rampart/payloads/_generator.py, rampart/probes/__init__.py,
  rampart/probes/_single_turn.py, rampart/pytest_plugin/_collection.py,
  rampart/pytest_plugin/_session.py, rampart/pytest_plugin/plugin.py,
  rampart/reporting/json_file.py, rampart/surfaces/onedrive.py,
  rampart/_pyrit/llm_bridge.py, rampart/evaluators/response_contains.py,
  tests/fixtures.py

TRY003/EM101/EM102 (50 fixes) - extracted exception messages to msg variable:
  rampart/_pyrit/llm_bridge.py:86-91, rampart/converters/docx.py:63-64,
  rampart/core/execution.py:146-148, rampart/core/types.py:119-131,217-218,300,
  rampart/drivers/__init__.py:37-39, rampart/payloads/__init__.py:144,
  rampart/payloads/_store.py:82,135-138,191-192,201-202,350,
  rampart/probes/__init__.py:87-88, rampart/pytest_plugin/_session.py:104-106,
  rampart/pytest_plugin/plugin.py:111-116,200-201,
  rampart/surfaces/onedrive.py:95-97,104-107,119-121,180-182

PYI034 (9 fixes) - changed __aenter__ return type to Self:
  rampart/core/adapter.py:42, rampart/core/injection.py:41,
  rampart/surfaces/onedrive.py:171, tests/fixtures.py:43,
  tests/unit/core/test_execution.py:25, tests/unit/core/test_protocols.py:23,43,89,118

PYI036/ANN401 (9 fixes) - changed exc_tb: Any to types.TracebackType | None:
  rampart/core/adapter.py:51, rampart/core/injection.py:50,
  rampart/surfaces/onedrive.py:203, tests/fixtures.py:53,
  tests/unit/core/test_execution.py:33, tests/unit/core/test_protocols.py:30,50,96,125

D107 (8 fixes) - added __init__ docstrings:
  rampart/converters/docx.py:34, rampart/core/execution.py:182,
  rampart/drivers/static.py:25, rampart/evaluators/response_contains.py:23,
  rampart/evaluators/side_effect.py:19, rampart/evaluators/tool_called.py:26,
  rampart/reporting/json_file.py:39, rampart/surfaces/onedrive.py:51

D205 (3 fixes) - inserted blank line after docstring summary:
  rampart/core/execution.py:201, rampart/pytest_plugin/plugin.py:122,
  tests/fixtures.py:57

E501 (10 fixes) - shortened lines exceeding 88 chars:
  rampart/core/execution.py:78, rampart/core/manifest.py:88,97,
  rampart/core/result.py:137, rampart/evaluators/response_contains.py:19,
  rampart/probes/_single_turn.py:104, rampart/pytest_plugin/_session.py:106,
  tests/fixtures.py:86, tests/unit/attacks/test_xpia.py:72,
  tests/unit/core/test_result.py:1

SLF001 (8 fixes) - added public properties to OneDriveSurface (drive_id,
  folder_path, indexing_delay), updated _OneDriveInjection to use them:
  rampart/surfaces/onedrive.py:159,174,181-182,195,200

PLW2901 (2 fixes) - renamed loop variables to avoid reassignment:
  rampart/payloads/_store.py:143-144 (line -> raw_line)
  rampart/pytest_plugin/_session.py:146 (result -> original_result)

PLR2004 (1 fix) - extracted magic value to _PREVIEW_MAX_LENGTH constant:
  rampart/core/types.py:136-137

RUF006 (1 fix) - stored create_task return value:
  rampart/pytest_plugin/plugin.py:523

noqa suppressions introduced (29 total):
  rampart/_pyrit/llm_bridge.py:128,130       PLC0415  deferred pyrit imports
  rampart/converters/docx.py:41              PLC0415  lazy pyrit converter import
  rampart/core/execution.py:314              BLE001   handler safety catch
  rampart/evaluators/side_effect.py:19       ANN401   **kwargs API design
  rampart/evaluators/tool_called.py:26       ANN401   **kwargs API design
  rampart/payloads/__init__.py:92            PLR0913  factory method
  rampart/probes/__init__.py:56              PLR0913  factory method
  rampart/probes/__init__.py:98              S101     type narrowing assert
  rampart/pytest_plugin/plugin.py:223-224    SLF001   pytest item private attrs
  rampart/pytest_plugin/plugin.py:240        ARG001   pytest hook signature
  rampart/pytest_plugin/plugin.py:297        BLE001   plugin safety catch
  rampart/pytest_plugin/plugin.py:458        ARG001   pytest hook signature
  rampart/pytest_plugin/plugin.py:496        BLE001   sink teardown safety
  rampart/pytest_plugin/plugin.py:523        RUF006   fire-and-forget task
  rampart/pytest_plugin/plugin.py:528,559,580 ANN401  no public type for terminalreporter
  rampart/pytest_plugin/plugin.py:581        ARG001   pytest hook signature
  rampart/surfaces/onedrive.py:202           SLF001   inner class -> parent._upload_async
  rampart/surfaces/onedrive.py:226           SLF001   inner class -> parent._delete_async
  rampart/surfaces/onedrive.py:227           BLE001   cleanup must not raise
  tests/unit/pytest_plugin/test_plugin.py:35-51  ANN401 x6  _StashStub dict mock
  tests/unit/surfaces/test_onedrive.py:25    ANN401   sentinel default
  tests/unit/surfaces/test_onedrive.py:63    ANN401   mock dispatch return

@nina-msft Nina Chikanov (nina-msft) 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.

🫡

@spencrr
Spencer Schoenberg (spencrr) merged commit 08615af into main Apr 15, 2026
4 checks passed
@spencrr
Spencer Schoenberg (spencrr) deleted the spencrr/lint-project-files branch April 22, 2026 04:48
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