From 19e82fd357a5dd613992d5a553c2befc63cbdf55 Mon Sep 17 00:00:00 2001 From: dorschw <81086590+dorschw@users.noreply.github.com> Date: Sat, 12 Aug 2023 14:41:51 +0300 Subject: [PATCH] add `README.md`, `LICENSE.md` --- LICENSE.md | 20 ++++++++++++++++++++ README.md | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ poetry.lock | 8 ++++---- pyproject.toml | 1 - 4 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..8912dc7 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,20 @@ +Copyright (c) 2023 Dorschw + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md index e69de29..273374c 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,50 @@ + +# Riff +Ruff + diff = Riff + +Run [**Ruff**](https://ruff.rs)⚡, 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. + +## Badges + +[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v1.json)](https://github.com/charliermarsh/ruff) +[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) +[![MIT License](https://img.shields.io/badge/License-MIT-green.svg)](https://choosealicense.com/licenses/mit/) + +## 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`](https://pre-commit.com/#plugins) file +#### +``` +- repo: https://github.com/dorschw/riff + hooks: + - id: riff + rev: 0.0.284a1 +``` + +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](https://dailystuff.nl/blog/2023/extending-github-actions-with-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](https://beta.ruff.rs/docs/configuration/) to, regardless of the modified lines. Riff cannot control this behavior. +* Riff cannot _currently_ run Ruff with a `--format` configuration. (see [here](https://github.com/dorschw/riff/issues/9)) diff --git a/poetry.lock b/poetry.lock index c2b9504..406c790 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1147,13 +1147,13 @@ files = [ [[package]] name = "virtualenv" -version = "20.24.2" +version = "20.24.3" description = "Virtual Python Environment builder" optional = false python-versions = ">=3.7" files = [ - {file = "virtualenv-20.24.2-py3-none-any.whl", hash = "sha256:43a3052be36080548bdee0b42919c88072037d50d56c28bd3f853cbe92b953ff"}, - {file = "virtualenv-20.24.2.tar.gz", hash = "sha256:fd8a78f46f6b99a67b7ec5cf73f92357891a7b3a40fd97637c27f854aae3b9e0"}, + {file = "virtualenv-20.24.3-py3-none-any.whl", hash = "sha256:95a6e9398b4967fbcb5fef2acec5efaf9aa4972049d9ae41f95e0972a683fd02"}, + {file = "virtualenv-20.24.3.tar.gz", hash = "sha256:e5c3b4ce817b0b328af041506a2a299418c98747c4b1e68cb7527e74ced23efc"}, ] [package.dependencies] @@ -1193,4 +1193,4 @@ dev = ["black (>=19.3b0)", "pytest (>=4.6.2)"] [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "afdd43329be02ab5f4c17305fcb9a7cd2a0eb924b4853edd7ee5d3f96cfebc67" +content-hash = "cadf17db107548d2454ffde8fce979dec8061872d3b15aadedb8203c530f9dbe" diff --git a/pyproject.toml b/pyproject.toml index f056175..0718b23 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,7 +24,6 @@ ipykernel = "^6.25.1" [tool.poetry.scripts] riff = "riff.riff:app" - [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api"