Skip to main content

Run ruff, but only fail on modified lines.

Project description

Riff

PyPI version Ruff Black MIT License

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 riff without 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 (default false). When set to true, will add GitHub Annotations, making the violations more visible when reviewing code in GitHub's Modified Files tab.
  • base-branch: string (default origin/main). Change to origin/master or whatever your base branch is named.

Limitations

  • When using Ruff's --fix feature, 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-format configuration. (see here)

Alternatives

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

riff-0.1.tar.gz (73.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

riff-0.1-py3-none-any.whl (11.0 kB view details)

Uploaded Python 3

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

Hashes for riff-0.1.tar.gz
Algorithm Hash digest
SHA256 ccc1fee61a6888187b473ce0f6cd4c1484c40a88df179241c2c81e107e5770e1
MD5 e24315605577ee409be6251c1eb24ad1
BLAKE2b-256 c2f87db4d00938d42f7a667b995a03fa1170e84b5af679464fe055f9f469ccfd

See more details on using hashes here.

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

Hashes for riff-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3a4b38e25af8ba02fc553834cd79e3d075152984c67f8143d3ef21c7b609add2
MD5 84628a5b679f59621394f7c9ed047c5a
BLAKE2b-256 94f1f97e52af42b800a89e3e7cbc5088668957376e97e68dded992fb24242f52

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page