Skip to content

Ruff explicit support#7

Merged
ofekby merged 6 commits intomainfrom
ruff-explicit-support
Feb 16, 2026
Merged

Ruff explicit support#7
ofekby merged 6 commits intomainfrom
ruff-explicit-support

Conversation

@ofekby
Copy link
Collaborator

@ofekby ofekby commented Jan 10, 2026

Addresses #6

This pull request adds first-class support for the Ruff linter to snaplint, ensuring that Ruff's output is correctly detected and handled independently from Flake8, even though they share a similar output format. The changes include updates to linter detection logic, parsing, documentation, and comprehensive end-to-end tests to verify correct behavior.

Linter detection and parsing improvements:

  • Enhanced the _detect_linter_from_lines function in src/snaplint/cli.py to reliably distinguish Ruff output from Flake8, using Ruff-specific summary lines and [ * ] markers, and updated the logic to prioritize Ruff detection. [1] [2]
  • Added a dedicated Ruff regex pattern RUFF_RE in src/snaplint/parse.py and updated _parse_line to assign the correct tool ("ruff" or "flake") based on the presence of the [ * ] marker in the message. [1] [2]
  • Updated the tool type in IssueLine (in src/snaplint/models.py) to include "ruff" as a valid value.

Documentation updates:

  • Updated README.md to document Ruff as a supported linter, including usage instructions and auto-detection behavior. [1] [2]

Testing enhancements:

  • Added comprehensive end-to-end tests in tests/test_e2e.py to verify Ruff support, including auto-detection, distinction from Flake8, and correct snapshot/diff workflows.
  • Extended unit tests in tests/test_parse.py to cover Ruff-specific output lines and ensure correct parsing.

Other changes:

  • Bumped the project version to 1.0.0 in pyproject.toml to reflect the new major feature.
  • Added missing import for re in src/snaplint/cli.py.

Breaking Change

This PR changes how Ruff linter output is detected. Previously, Ruff's concise output was incorrectly detected as Flake8 (since they share the same format), resulting in snapshots being saved to .snaplint/snapshot.flake8.json.gz.

Now, Ruff output is correctly detected and saved to .snaplint/snapshot.ruff.json.gz.

Migration
If you were using Ruff but your snapshots were saved as snapshot.flake8.json.gz, you have two options:

  • Option 1: Rename your existing snapshot (recommended)
mv .snaplint/snapshot.flake8.json.gz .snaplint/snapshot.ruff.json.gz
  • Option 2: Use explicit snapshot path
# Take snapshot
ruff check --output-format concise . | snaplint take-snapshot .snaplint/snapshot.flake8.json.gz

# Diff
ruff check --output-format concise . | snaplint diff .snaplint/snapshot.flake8.json.gz

Continue using your existing snapshot by specifying the path explicitly:

This bypasses auto-detection and uses the specified snapshot file directly.

- Introduced regex patterns for detecting Ruff output in cli.py and parse.py.
- Updated IssueLine model to include 'ruff' as a tool option.
- Added end-to-end tests for Ruff integration in test_e2e.py and test_parse.py.
- Created a snapshot file for Ruff outputs.
Copilot AI review requested due to automatic review settings January 10, 2026 16:25
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds first-class support for the Ruff linter to snaplint, enabling it to detect and handle Ruff output independently from Flake8 despite their similar output formats. The implementation includes linter detection improvements, parsing enhancements, comprehensive tests, and updated documentation.

Changes:

  • Enhanced linter detection logic to distinguish Ruff from Flake8 using summary lines and [*] markers
  • Added Ruff-specific regex pattern and parsing logic to correctly identify Ruff output
  • Comprehensive E2E and unit tests covering Ruff auto-detection, distinction from Flake8, and workflow scenarios
  • Updated documentation to include Ruff as a supported linter with usage instructions
  • Bumped version to 1.0.0 to reflect the new major feature

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/snaplint/cli.py Added re import, RUFF_SUMMARY_RE pattern, and enhanced _detect_linter_from_lines to detect Ruff using summary lines and [*] markers
src/snaplint/parse.py Added RUFF_RE pattern and updated _parse_line to distinguish Ruff from Flake8 based on [*] marker
src/snaplint/models.py Extended IssueLine.tool type to include "ruff" as a valid value
tests/test_parse.py Added unit tests for Ruff-specific output lines with and without [*] markers
tests/test_e2e.py Added comprehensive E2E tests for Ruff auto-detection, distinction from Flake8, and full workflow scenarios
README.md Updated documentation to include Ruff as a supported linter with usage examples
pyproject.toml Bumped version from 0.6.0 to 1.0.0

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ofekby ofekby merged commit a0a6660 into main Feb 16, 2026
8 checks passed
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.

2 participants