Skip to content

chore(lint): apply ruff's safe autofixes (Optional[X], __all__ order, regex flags) - #198

Merged
vsn411 merged 4 commits into
secfoo-com:mainfrom
Labu1:repodestek/issue-165
Nov 26, 2026
Merged

vsn411 merged 4 commits into
secfoo-com:mainfrom
Labu1:repodestek/issue-165

Conversation

@Labu1

@Labu1 Labu1 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Closes #165

What does this change, and why?

ruff check . reports a backlog of findings, so CI runs it with || true and lint never blocks (#114). This PR applies the mechanical, safe fixes from #165:

  • UP045: Optional[X] -> X | None in src/secfoo/cli.py and src/secfoo/web/routes/assessments.py (60 annotations). The now-unused typing.Optional imports are removed. Both modules use from __future__ import annotations, and the typer/FastAPI versions the project requires resolve PEP 604 unions on Python 3.10+.
  • FURB167: re.S -> re.DOTALL in three tests/test_web/ files.
  • RUF022: sorted __all__ in secfoo.agents, secfoo.skills and secfoo.targets.
  • UP037: unquoted the RunRepository.__enter__ return annotation.

The only changes are to annotations, __all__ order and regex flag names. Nothing else changes, and behavior is unchanged. The remaining rules in the issue (I001 import order, RUF100 unused noqa, FURB188, F401) are not in this change and may still need a ruff check . --fix pass.

Fixes #165

Testing

Not run locally.

  • pytest tests passes
  • ruff check . passes
  • Added/updated tests for the behavior change

This PR was prepared with AI assistance (Claude) and reviewed by me before submitting.

Apply the mechanical, behavior-preserving fixes ruff reports so lint
can eventually block in CI (secfoo-com#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 secfoo-com#165.
@Labu1
Labu1 requested a review from vsn411 as a code owner November 26, 2026 07:44
vsn411 and others added 2 commits November 26, 2026 15:39
…used 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 secfoo-com#196, which returns Self there.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vsn411

vsn411 commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

Thanks, and welcome! Your changes are all correct. I pushed a commit to your branch (10151ce) that finishes the rest of #165, so you don't need another round:

  • Ran ruff check . --fix (safe fixes only) for I001, RUF100 and FURB188.
  • Where an unused noqa was removed, I kept its reason as a plain comment (S608, A002). The bandit # nosec B310 comments stay.
  • One catch worth knowing: ruff's F401 fix would delete SKILL_ID from web/sast_dashboard.py, but routes/activities.py uses it as sast_dashboard.SKILL_ID. Deleting it would break the dashboard at runtime, so the import stays with a noqa: F401 comment saying why.
  • tests/fixtures is now excluded from ruff. Those files are byte-exact inputs checked by SHA-256, and import sorting would change their digests.
  • I left RunRepository.__enter__ to fix(lint): resolve the error-handling ruff findings in src #196, which returns Self there, so the two PRs don't conflict.

After this, ruff check . shows none of #165's rules. The remaining findings belong to #168 (#196). We'll merge once CI is approved and green.

from dataclasses import dataclass, field

from secfoo.report.sast import SKILL_ID
from secfoo.report.sast import SKILL_ID # noqa: F401 -- re-exported: routes/activities.py uses sast_dashboard.SKILL_ID
@vsn411
vsn411 merged commit 6f37e7e into secfoo-com:main Nov 26, 2026
15 checks passed
@github-actions

Copy link
Copy Markdown

Leaderboard update

Labu1 now has 3 points (rank #14). 22 more to reach Bronze.

Full leaderboard

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.

Lint: apply ruff's safe autofixes (98 errors: Optional[X], import order, unused noqa)

3 participants