Run ruff, but only fail on modified lines.
Project description
Riff
Ruff + diff = Riff
Run Ruff⚡, and filter out violations not caused by your branch.
Riff uses git diff to detect code lines modified in the current branch, and filters Ruff's output accordingly.
Riff only fails when violations are detected in modified lines.
Rationale
Ruff doesn't have a baseline feature, so Riff can come handy for enforcing Ruff rules in larger repositories quickly, without having to fix every single existing violation.
Usage
As a CLI tool
- Make sure Ruff (>=0.0.291) is installed
- Run
riff, followed by (optional) Riff arguments, and (optional) Ruff arguments. - Running
riffwithout arguments will run it in the current directory. - Riff expects to be run in a repository folder.
As a pre-commit hook
Copy this to your .pre-commit-config file
- repo: https://github.com/dorschw/riff
rev: v0.1
hooks:
- id: riff
additional_dependencies: ["ruff>=0.0.291"] # minimal is 0.0.291, consider using the latest version
To pass other arguments to Riff (and Ruff), add the args key, e.g.
args: ["--base-branch=origin/master"]
Riff Arguments
always-fail-on: comma-separated list of Ruff error codes. When detected by Ruff, Riff will consider them as failures, even if they're not in lines modified in the current branch.print-github-annotation: boolean (defaultfalse). When set totrue, will add GitHub Annotations, making the violations more visible when reviewing code in GitHub'sModified Filestab.base-branch: string (defaultorigin/main). Change toorigin/masteror whatever your base branch is named.
Limitations
- When using Ruff's
--fixfeature, Ruff will fix everything it is configured to, regardless of the modified lines. Riff cannot control this behavior. - Riff cannot currently run Ruff with a
--output-formatconfiguration. (see here)
Alternatives
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file riff-0.1.tar.gz.
File metadata
- Download URL: riff-0.1.tar.gz
- Upload date:
- Size: 73.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccc1fee61a6888187b473ce0f6cd4c1484c40a88df179241c2c81e107e5770e1
|
|
| MD5 |
e24315605577ee409be6251c1eb24ad1
|
|
| BLAKE2b-256 |
c2f87db4d00938d42f7a667b995a03fa1170e84b5af679464fe055f9f469ccfd
|
File details
Details for the file riff-0.1-py3-none-any.whl.
File metadata
- Download URL: riff-0.1-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a4b38e25af8ba02fc553834cd79e3d075152984c67f8143d3ef21c7b609add2
|
|
| MD5 |
84628a5b679f59621394f7c9ed047c5a
|
|
| BLAKE2b-256 |
94f1f97e52af42b800a89e3e7cbc5088668957376e97e68dded992fb24242f52
|