Skip to content

Commit 70a759e

Browse files
committed
Address Codacy findings on PR #97
Pyflakes (84 unused imports): bulk-stripped via autoflake across 64 files in je_web_runner/utils/ and test/unit_test/. Pylint: - E1111 assignment-from-no-return on exploratory_ai Protocol-method calls (observer.observe, planner.plan): added `# pylint: disable=...` with reason; Protocol bodies are `...` so Pylint can't see the real impl - E1102 not-callable on grpc_tester code_obj(): guarded by callable() check; suppressed with reason - W0622 redefined-builtin 'format' in webhook_receiver + live_dashboard log_message overrides: keep the stdlib signature name and disable redefined-builtin Bandit: - B311 PRNG in chaos_hooks, flag_matrix, exploratory_ai, mutation_testing: `# nosec B311 — deterministic seeded scheduling / sampling / fuzz, not cryptographic` - B310 urlopen in test_webhook_receiver: `# nosec B310 — fixture talks only to the local WebhookServer (random loopback port)` - B404 subprocess import in test_test_auto_repair + repair.py: `# nosec B404` — subprocess is intentional for git diff capture - B105 hardcoded "pass" verdict literal in multimodal_qa Verdict enum: `# nosec B105 — verdict label, not a credential` - B112 try/except/continue in indexed_db_explorer.find_one, webhook_receiver.assert_received_json_matching, sse_assert. assert_received_event: `# nosec B112 — user predicate may legitimately raise; skip + continue` - B110 try/except/pass in otp_interceptor IMAP cleanup: `# nosec B110 — best-effort cleanup; swallowing is intentional` - B104 "0.0.0.0" set-membership compare in live_dashboard: `# nosec B104 — string compare detecting "bind all"; rewritten to 127.0.0.1` Semgrep: - dangerous-subprocess-use in test_test_auto_repair: `# nosemgrep` on MagicMock(return_value=subprocess.CompletedProcess(...)) — no subprocess is actually launched - aws-access-token in test_token_leak_detector fixtures: `# nosemgrep` — the literal AKIA... string is the fixture exercising the detector itself All 2920 unit tests pass.
1 parent 98cab2b commit 70a759e

73 files changed

Lines changed: 82 additions & 108 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

je_web_runner/utils/bug_repro_stability/stability.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
"""
1212
from __future__ import annotations
1313

14-
import time
1514
from dataclasses import asdict, dataclass, field
1615
from enum import Enum
17-
from typing import Any, Callable, Dict, List, Optional, Sequence
16+
from typing import Any, Callable, Dict, List, Optional
1817

1918
from je_web_runner.utils.exception.exceptions import WebRunnerException
2019
from je_web_runner.utils.logging.loggin_instance import web_runner_logger

je_web_runner/utils/bundle_budget/budget.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
from __future__ import annotations
77

88
import json
9-
from dataclasses import asdict, dataclass, field
9+
from dataclasses import dataclass, field
1010
from enum import Enum
11-
from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union
11+
from typing import Any, Dict, List, Sequence, Tuple, Union
1212
from urllib.parse import urlparse
1313

1414
from je_web_runner.utils.exception.exceptions import WebRunnerException

je_web_runner/utils/chaos_hooks/chaos.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def plan_chaos(
9494
if skip_first < 0 or skip_last < 0:
9595
raise ChaosHooksError("skip_first / skip_last must be >= 0")
9696
total = len(step_names)
97-
rng = random.Random(seed)
97+
rng = random.Random(seed) # nosec B311 — deterministic test scheduling, not crypto
9898
events: List[ChaosEvent] = []
9999
skipped: List[int] = []
100100
for index, name in enumerate(step_names):

je_web_runner/utils/clickjacking_audit/audit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import re
1919
from dataclasses import asdict, dataclass, field
2020
from enum import Enum
21-
from typing import Any, Callable, Dict, Iterable, List, Optional, Sequence, Tuple
21+
from typing import Any, Dict, Iterable, List, Optional, Tuple
2222
from urllib.parse import urlparse
2323

2424
from je_web_runner.utils.exception.exceptions import WebRunnerException

je_web_runner/utils/consent_audit/audit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from __future__ import annotations
1515

1616
import re
17-
from dataclasses import asdict, dataclass, field
17+
from dataclasses import dataclass, field
1818
from enum import Enum
1919
from typing import Any, Dict, Iterable, List, Optional, Sequence
2020

je_web_runner/utils/coop_coep_audit/audit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import json
1818
from dataclasses import asdict, dataclass, field
1919
from enum import Enum
20-
from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union
20+
from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
2121
from urllib.parse import urlparse
2222

2323
from je_web_runner.utils.exception.exceptions import WebRunnerException

je_web_runner/utils/db_snapshot/snapshot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import contextlib
1616
import uuid
1717
from dataclasses import dataclass, field
18-
from typing import Any, Callable, Dict, List, Optional, Protocol
18+
from typing import Any, Callable, Dict, List, Protocol
1919

2020
from je_web_runner.utils.exception.exceptions import WebRunnerException
2121
from je_web_runner.utils.logging.loggin_instance import web_runner_logger

je_web_runner/utils/exploratory_ai/explorer.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def __init__(
152152
) -> None:
153153
if not 0.0 <= type_bias <= 1.0:
154154
raise ExploratoryAiError("type_bias must be in [0, 1]")
155-
self._rng = random.Random(seed)
155+
self._rng = random.Random(seed) # nosec B311 — deterministic fuzz, not crypto
156156
self._samples = list(sample_strings) or ["x"]
157157
self._type_bias = type_bias
158158

@@ -244,6 +244,8 @@ def run(self) -> ExplorationReport: # NOSONAR S3776 — cohesive logic; planned
244244

245245
def _safe_observe(self, step: int) -> PageObservation:
246246
try:
247+
# pylint: disable=assignment-from-no-return — Protocol body is `...`;
248+
# pylint can't see the real implementation's return.
247249
obs = self.observer.observe(step)
248250
except Exception as error:
249251
raise ExploratoryAiError(
@@ -262,6 +264,7 @@ def _safe_plan(
262264
repeat_counter: Dict[str, int],
263265
) -> Optional[PlannedAction]:
264266
try:
267+
# pylint: disable=assignment-from-no-return — Protocol body is `...`.
265268
action = self.planner.plan(observation)
266269
except Exception as error:
267270
web_runner_logger.warning(f"planner failed; stopping: {error!r}")

je_web_runner/utils/failure_narrator/narrator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import json
1414
from dataclasses import asdict, dataclass, field
1515
from pathlib import Path
16-
from typing import Any, Dict, List, Optional, Protocol, Sequence, Union
16+
from typing import Any, Dict, List, Protocol, Sequence, Union
1717

1818
from je_web_runner.utils.exception.exceptions import WebRunnerException
1919

je_web_runner/utils/file_system_access/mock.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from __future__ import annotations
88

99
import json
10-
from dataclasses import asdict, dataclass, field
11-
from typing import Any, Callable, Dict, List, Optional, Sequence
10+
from dataclasses import asdict, dataclass
11+
from typing import Any, Dict, List, Optional, Sequence
1212

1313
from je_web_runner.utils.exception.exceptions import WebRunnerException
1414

0 commit comments

Comments
 (0)