Merged
Conversation
- 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.
There was a problem hiding this comment.
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.
… and add mypy linter tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
_detect_linter_from_linesfunction insrc/snaplint/cli.pyto reliably distinguish Ruff output from Flake8, using Ruff-specific summary lines and[ * ]markers, and updated the logic to prioritize Ruff detection. [1] [2]RUFF_REinsrc/snaplint/parse.pyand updated_parse_lineto assign the correct tool ("ruff"or"flake") based on the presence of the[ * ]marker in the message. [1] [2]tooltype inIssueLine(insrc/snaplint/models.py) to include"ruff"as a valid value.Documentation updates:
README.mdto document Ruff as a supported linter, including usage instructions and auto-detection behavior. [1] [2]Testing enhancements:
tests/test_e2e.pyto verify Ruff support, including auto-detection, distinction from Flake8, and correct snapshot/diff workflows.tests/test_parse.pyto cover Ruff-specific output lines and ensure correct parsing.Other changes:
1.0.0inpyproject.tomlto reflect the new major feature.reinsrc/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:
Continue using your existing snapshot by specifying the path explicitly:
This bypasses auto-detection and uses the specified snapshot file directly.