Skip to content

Commit c618c2a

Browse files
romanlutzCopilot
andauthored
MAINT: fix remaining pre-commit failures on main (ty + reST roles) (#1938)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 1e386ae commit c618c2a

7 files changed

Lines changed: 16 additions & 15 deletions

File tree

pyrit/auth/copilot_authenticator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ async def _run_playwright_browser_automation_async(self) -> Optional[str]:
380380
async with async_playwright() as playwright:
381381
browser = None
382382
context = None
383+
page = None
383384

384385
try:
385386
logger.info(f"Launching browser for authentication (headless={self._headless})...")

pyrit/auxiliary_attacks/gcg/data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
"""CSV → goals/targets loader for the GCG attack.
55
6-
Decoupled from :class:`GCGGenerator` so that callers with goals and targets
6+
Decoupled from ``GCGGenerator`` so that callers with goals and targets
77
already in memory can pass them straight into ``execute_async`` without going
88
through ``pandas`` or any filesystem access.
99
"""
@@ -34,7 +34,7 @@ def load_goals_and_targets(
3434
``train_data`` falls back to whatever default the legacy loader
3535
returns (an empty list today).
3636
random_seed (int): Seed used to shuffle the training rows. Defaults
37-
to ``42`` to match :class:`GCGAlgorithmConfig`'s default.
37+
to ``42`` to match ``GCGAlgorithmConfig``'s default.
3838
3939
Returns:
4040
tuple[list[str], list[str], list[str], list[str]]:

pyrit/auxiliary_attacks/gcg/experiments/run.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Copyright (c) Microsoft Corporation.
22
# Licensed under the MIT license.
33

4-
"""Thin CLI wrapper around :meth:`GCGGenerator.execute_async` for AzureML jobs.
4+
"""Thin CLI wrapper around ``GCGGenerator.execute_async`` for AzureML jobs.
55
6-
The notebook (or any user) builds a :class:`GCGConfig` (strategy) and a
7-
:class:`GCGDataConfig` (data) locally, serializes both with their respective
6+
The notebook (or any user) builds a ``GCGConfig`` (strategy) and a
7+
``GCGDataConfig`` (data) locally, serializes both with their respective
88
``to_json_file`` methods, ships them to Azure ML as job inputs, and the job's
99
command line is::
1010
@@ -14,7 +14,7 @@
1414
--output-dir ${{outputs.results}}
1515
1616
This file deserializes both configs inside the job, loads goals/targets from
17-
the configured CSV, and runs the attack via a fresh :class:`GCGGenerator`.
17+
the configured CSV, and runs the attack via a fresh ``GCGGenerator``.
1818
"""
1919

2020
import argparse

pyrit/cli/pyrit_shell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ def do_clear(self, arg: str) -> None:
572572
"""Clear the screen."""
573573
import os
574574

575-
os.system("cls" if os.name == "nt" else "clear")
575+
os.system("cls" if os.name == "nt" else "clear") # type: ignore[ty:deprecated]
576576

577577
# Shortcuts and aliases
578578
do_quit = do_exit

pyrit/output/score/pretty.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def _render_score(self, score: Score, indent_level: int = 3) -> str:
6565
"""
6666
lines: list[str] = []
6767
indent = self._indent * indent_level
68-
scorer_name = score.scorer_class_identifier.class_name
68+
scorer_name = (score.scorer_class_identifier.class_name if score.scorer_class_identifier else None) or "Unknown"
6969
lines.append(f"{indent}Scorer: {scorer_name}\n")
7070
lines.append(self._format_colored(f"{indent}• Category: {score.score_category or 'N/A'}", Fore.LIGHTMAGENTA_EX))
7171
lines.append(self._format_colored(f"{indent}• Type: {score.score_type}", Fore.CYAN))

pyrit/scenario/scenarios/adaptive/text_adaptive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class TextAdaptive(AdaptiveScenario):
9494

9595
_cached_strategy_class: ClassVar[type[ScenarioStrategy] | None] = None
9696

97-
VERSION: int = 1
97+
VERSION: ClassVar[int] = 1
9898

9999
@classmethod
100100
def _atomic_attack_prefix(cls) -> str:

pyrit/setup/initializers/components/scenario_techniques.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
Scenario technique initializer.
66
77
This module owns the canonical catalog of scenario attack techniques as a
8-
flat list of self-describing :class:`AttackTechniqueFactory` instances and
9-
registers them into the singleton :class:`AttackTechniqueRegistry` via
10-
:class:`ScenarioTechniqueInitializer`.
8+
flat list of self-describing ``AttackTechniqueFactory`` instances and
9+
registers them into the singleton ``AttackTechniqueRegistry`` via
10+
``ScenarioTechniqueInitializer``.
1111
1212
Per-name registration is idempotent: pre-existing entries in the registry are
1313
not overwritten.
@@ -41,14 +41,14 @@ def build_scenario_technique_factories() -> list[AttackTechniqueFactory]:
4141
4242
Factories that need an adversarial chat target do not bake one in; the
4343
default adversarial target is resolved lazily inside
44-
:meth:`AttackTechniqueFactory.create` via
44+
``AttackTechniqueFactory.create`` via
4545
``get_default_adversarial_target()``. Scenarios may also pass
4646
``attack_adversarial_config_override`` at create time (but only when the
4747
factory did not bake one in at construction).
4848
4949
A bare ``PromptSendingAttack`` factory is intentionally omitted from the
5050
catalog: every scenario whose ``BASELINE_ATTACK_POLICY`` is
51-
:attr:`BaselineAttackPolicy.Enabled` already auto-prepends an equivalent
51+
``BaselineAttackPolicy.Enabled`` already auto-prepends an equivalent
5252
baseline atomic attack via ``Scenario._build_baseline_atomic_attack``.
5353
5454
Returns:
@@ -120,7 +120,7 @@ class ScenarioTechniqueInitializer(PyRITInitializer):
120120
``Scenario._build_baseline_atomic_attack``) already covers that case.
121121
122122
Registration is per-name idempotent: pre-existing entries in
123-
:class:`AttackTechniqueRegistry` are not overwritten.
123+
``AttackTechniqueRegistry`` are not overwritten.
124124
"""
125125

126126
async def initialize_async(self) -> None:

0 commit comments

Comments
 (0)