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

Locally

  • Run riff, followed by Riff arguments (optional, see below), and Ruff arguments (optional, see limitations).
  • 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
  hooks:
  - id: riff
    rev: v0.0.287.0

To pass other arguments to Riff (and Ruff), add the args key, e.g.

    args: ["--base-branch=origin/master"]

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 --format configuration. (see here)

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.0.287.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

riff-0.0.287.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file riff-0.0.287.0.tar.gz.

File metadata

  • Download URL: riff-0.0.287.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.0 Linux/5.15.0-1041-azure

File hashes

Hashes for riff-0.0.287.0.tar.gz
Algorithm Hash digest
SHA256 82a670311fccbf2ae45202d7451b9b1883ad02b55928430dd38495f3e12113b3
MD5 9151a91934b9845339c114a851fac08e
BLAKE2b-256 8c0ee94ccf4bfb31a83d842f4dae5135ee7d48af1278725151b1f31a225440df

See more details on using hashes here.

File details

Details for the file riff-0.0.287.0-py3-none-any.whl.

File metadata

  • Download URL: riff-0.0.287.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.0 Linux/5.15.0-1041-azure

File hashes

Hashes for riff-0.0.287.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1d89f2f91f9fc7657e7a0489614c5143b4fe85189dc88f0a2963ef1305ef8483
MD5 738f35c2a6a15d17fc017e4330b48e09
BLAKE2b-256 29bb330beccf365f9d5e55f45224df7ba3bc0e8846d27b5be8951bf2352ca257

See more details on using hashes here.

Supported by

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