Skip to content

ci: Enforce Ruff lint and formatting - #139

Open
lelia wants to merge 1 commit into
mainfrom
lelia/enforce-ruff-lint-format
Open

lelia wants to merge 1 commit into
mainfrom
lelia/enforce-ruff-lint-format

Conversation

@lelia

@lelia lelia commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Ruff replaces Black and Flake8 and enforces linting and formatting on every pull request. Local commands and pre-commit hooks use the same locked Ruff version as CI.

Changes

  • Add an unconditional Lint workflow, make lint / make format / make hooks targets, and pre-commit hooks using Ruff 0.17.4. Preserve the repository's 100-character line length and Python 3.10 support.
  • Clear the maintained-code baseline and set complexity 12 and eight-argument limits. The 51 existing over-limit functions have individual suppressions; RUF100 rejects markers that become unnecessary.
  • Exclude deliberately vulnerable app_tests/ and tests/fixtures/ targets and the generated CWE catalog. The generator and other development scripts remain linted.
  • Preserve connector package exports, finding rule IDs, and the UTC trailing-Z notification format while modernizing imports, annotations, exception chaining, and subprocess handling. Add regression coverage for exports, rule labels, and timestamps.
  • Make release-validation scripts and tests use the existing TOML compatibility dependency on Python 3.10. Add contributor guidance and [Unreleased] changelog entries; release version metadata stays with the separate release-preparation workflow.

Validation

  • 516 tests passed, one skipped, on Python 3.12 with OpenGrep required, including Java scanner rule tests.
  • 516 tests passed, one skipped, on Python 3.10.
  • Ruff lint and format checks, pre-commit hooks, actionlint, and locked dependency validation.
  • Wheel and sdist builds, release metadata checks, and current-release documentation checks.
  • All GitHub checks pass, including the new Ruff gate, package or unit tests, dependency review, and CodeQL.
  • Fourth wall review of added comments/docstrings, policy explanations, contributor guidance, changelog, and this description.

This is the Basics rollout. Shared workflow extraction and the cross-repository policy floor remain separate work.

Refs CE-451

@lelia
lelia deployed to socket-firewall November 14, 2026 02:39 — with GitHub Actions Active
@lelia
lelia deployed to socket-firewall November 14, 2026 02:39 — with GitHub Actions Active
@socket-security-staging

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedpypi/​pre-commit@​4.6.293100100100100
Addedpypi/​ruff@​0.17.4100100100100100

View full report

@socket-security-staging

Copy link
Copy Markdown

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Priority Alert  (click "▶" to expand/collapse) Action
High priority
High CVE: pypi filelock ReadWriteLock: SQLite reopens the lock database by name, so a planted symlink or journal file makes the lock user's process overwrite or unlink its own files

CVE: GHSA-v4x8-3wr5-3wq8 filelock ReadWriteLock: SQLite reopens the lock database by name, so a planted symlink or journal file makes the lock user's process overwrite or unlink its own files (HIGH)

Affected versions: >= 3.20.4 < 4.2.1

Patched version: 4.2.1

From: uv.lock → pypi/pre-commit@4.6.2 → pypi/filelock@4.1.0

ℹ Read more on: This package | This alert | What is a CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known high severity CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity-Staging ignore pypi/filelock@4.1.0. You can also ignore all packages with @SocketSecurity-Staging ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn

View full report

@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedpypi/​pre-commit@​4.6.293100100100100
Addedpypi/​ruff@​0.17.4100100100100100

View full report

@lelia
lelia marked this pull request as ready for review November 14, 2026 02:46
@lelia
lelia requested a review from a team as a code owner November 14, 2026 02:46
@cursor

cursor Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Primarily tooling and mechanical style changes with broad test/CI validation; limited intentional runtime tweaks (e.g. UTC timestamps, script compatibility).

Overview
Ruff replaces Black and Flake8 as the single linter and formatter, with a new GitHub Actions Lint workflow, Makefile targets (lint, format, hooks), and pre-commit hooks—all pinned to the same locked Ruff 0.17.4 via uv.

pyproject.toml drops Black/Flake8, adds a broad [tool.ruff] profile (100-char lines, Python 3.10 floor, complexity 12 and 8 max args, RUF100 to drop stale # noqa), and excludes vulnerable app_tests/, tests/fixtures/, and generated cwe_catalog.py.

The rest of the diff is largely Ruff-driven cleanup across scripts and socket_basics/ (modern typing, import order, formatting, targeted noqa: C901 on already-complex functions). Release/maintenance scripts gain tomlli fallbacks for Python 3.10. Changelog also notes timezone-aware UTC timestamps in notification formatters while keeping trailing-Z JSON output.

Reviewed by Cursor Bugbot for commit 2c704ef. Configure here.

@lelia
lelia deployed to socket-firewall November 14, 2026 02:46 — with GitHub Actions Active
@lelia

lelia commented Nov 14, 2026

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 2c704ef. Configure here.

This branch was successfully deployed

1 active deployment
socket-firewall — 2c704efe Deployed Nov 14, 2026 by lelia via python-sfw-smoke-enterprise #207
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.

1 participant