Skip to content

Commit 6f37e7e

Browse files
Labu1vsn411claude
authored
chore(lint): apply ruff's safe autofixes (Optional[X], __all__ order, regex flags) (#198)
* chore(lint): apply ruff's safe autofixes Apply the mechanical, behavior-preserving fixes ruff reports so lint can eventually block in CI (#114): - UP045: Optional[X] -> X | None in cli.py and the assessments routes, dropping the now-unused typing.Optional imports - FURB167: re.S -> re.DOTALL in the dashboard tests - RUF022: sort __all__ in agents, skills and targets packages - UP037: unquote the RunRepository.__enter__ return annotation Only annotations, __all__ order and regex flag names change; there is no behavior change. Fixes #165. * chore(lint): finish #165's safe autofixes (import order, unused noqa, removesuffix) - ruff check . --fix for I001, RUF100 and FURB188. - Kept the reasons where an unused noqa was removed (S608, A002); the nosec B310 comments for bandit stay. - F401 on sast_dashboard.SKILL_ID is a re-export used by routes/activities.py, so it keeps the import with a noqa instead of deleting it. - tests/fixtures is excluded from ruff: those files are byte-exact inputs checked by SHA-256, so lint must not rewrite them. - Left RunRepository.__enter__ to #196, which returns Self there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: aitechnology <40792067+vsn411@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 5db1681 commit 6f37e7e

23 files changed

Lines changed: 113 additions & 89 deletions

‎fuzz/fuzz_runtime_ingest.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
def check(data: bytes) -> None:
4242
for table in _INGEST_TABLES:
43-
_repo.connection.execute(f"DELETE FROM {table}") # noqa: S608 -- fixed table names
43+
_repo.connection.execute(f"DELETE FROM {table}") # fixed table names, not input
4444
_repo.connection.commit()
4545
lines = data.decode("utf-8", errors="replace").splitlines() # exactly as post_events decodes
4646
lines = _with_app_env(lines, "fuzz-app", "fuzz-env")

‎pyproject.toml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ packages = ["src/secfoo"]
109109
[tool.pytest.ini_options]
110110
testpaths = ["tests"]
111111

112+
[tool.ruff]
113+
# Adversarial and fuzz fixtures are exact byte inputs, checked by SHA-256
114+
# (scripts/adversarial_eval.py corpus_digest); lint must never rewrite them.
115+
extend-exclude = ["tests/fixtures"]
116+
112117
[tool.ruff.lint.flake8-bugbear]
113118
# typer.Option and FastAPI's Form are designed to be used as parameter
114119
# defaults (they describe the parameter, they aren't shared mutable state),

‎src/secfoo/agents/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from secfoo.agents.base import AgentAdapter, AgentResult
22
from secfoo.agents.registry import ADAPTERS, get_adapter
33

4-
__all__ = ["AgentAdapter", "AgentResult", "ADAPTERS", "get_adapter"]
4+
__all__ = ["ADAPTERS", "AgentAdapter", "AgentResult", "get_adapter"]

‎src/secfoo/agents/registry.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
from secfoo.agents.api import ApiAdapter
55
from secfoo.agents.base import AgentAdapter
66
from secfoo.agents.claude import ClaudeAdapter
7-
from secfoo.agents.copilot import CopilotAdapter
87
from secfoo.agents.codex import CodexAdapter
8+
from secfoo.agents.copilot import CopilotAdapter
99
from secfoo.agents.cursor import CursorAdapter
1010
from secfoo.agents.devin import DevinAdapter
1111
from secfoo.agents.droid import DroidAdapter

‎src/secfoo/cli.py‎

Lines changed: 55 additions & 55 deletions
Large diffs are not rendered by default.

‎src/secfoo/cloud.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def _request(url: str, *, api_key: str, payload: dict | None = None) -> dict:
133133
headers["Content-Type"] = "application/json"
134134
request = urllib.request.Request(url, data=data, headers=headers)
135135
try:
136-
with urllib.request.urlopen(request, timeout=REQUEST_TIMEOUT_SECONDS) as response: # noqa: S310 # nosec B310 -- user-configured portal URL, same trust as MCP settings
136+
with urllib.request.urlopen(request, timeout=REQUEST_TIMEOUT_SECONDS) as response: # nosec B310 -- user-configured portal URL, same trust as MCP settings
137137
return json.loads(response.read().decode("utf-8"))
138138
except urllib.error.HTTPError as exc:
139139
detail = exc.read().decode("utf-8", errors="replace")

‎src/secfoo/memory.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ def _request(url: str, *, payload: dict | None = None, api_key: str | None = Non
175175
headers["Content-Type"] = "application/json"
176176
request = urllib.request.Request(url, data=data, headers=headers)
177177
try:
178-
with urllib.request.urlopen(request, timeout=REQUEST_TIMEOUT_SECONDS) as response: # noqa: S310 # nosec B310 -- user-configured memory URL, same trust as MCP settings
178+
with urllib.request.urlopen(request, timeout=REQUEST_TIMEOUT_SECONDS) as response: # nosec B310 -- user-configured memory URL, same trust as MCP settings
179179
return json.loads(response.read().decode("utf-8") or "{}")
180180
except urllib.error.HTTPError as exc:
181181
detail = exc.read().decode("utf-8", errors="replace")

‎src/secfoo/osv.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def query_osv(ecosystem: str, package: str, version: str) -> list[dict]:
7777
OSV_API_URL, data=body, headers={"Content-Type": "application/json"}, method="POST"
7878
)
7979
try:
80-
with urllib.request.urlopen(request, timeout=REQUEST_TIMEOUT_SECONDS) as response: # noqa: S310 # nosec B310 -- hardcoded public OSV.dev API URL
80+
with urllib.request.urlopen(request, timeout=REQUEST_TIMEOUT_SECONDS) as response: # nosec B310 -- hardcoded public OSV.dev API URL
8181
data = json.loads(response.read().decode("utf-8"))
8282
except urllib.error.HTTPError as exc:
8383
detail = exc.read().decode("utf-8", errors="replace")

‎src/secfoo/runner.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ class RunOutcome:
139139
def _project_display_name(resolved: ResolvedTarget) -> str:
140140
if resolved.is_temporary:
141141
cleaned = resolved.display_name.rstrip("/")
142-
if cleaned.endswith(".git"):
143-
cleaned = cleaned[: -len(".git")]
142+
cleaned = cleaned.removesuffix(".git")
144143
match = re.search(r"(?:https?://[^/]+/|git@[^:]+:)(.+)$", cleaned)
145144
return match.group(1) if match else cleaned
146145
return Path(resolved.display_name).name or resolved.display_name

‎src/secfoo/skills/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
__all__ = [
55
"Skill",
66
"SkillLoadError",
7+
"TargetContext",
78
"load_all_skills",
89
"load_skill",
9-
"TargetContext",
1010
"render_prompt",
1111
]

0 commit comments

Comments
 (0)