From c52fdfa7486389c4376749c3f6965654b48a6347 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Sat, 27 Aug 2022 18:30:30 -0400 Subject: [PATCH] Rename to ruff (#29) --- .github/workflows/ci.yaml | 2 +- .gitignore | 3 +-- Cargo.lock | 2 +- Cargo.toml | 4 ++-- README.md | 26 +++++++++++----------- src/bin/{rust_python_linter.rs => ruff.rs} | 16 ++++++------- 6 files changed, 26 insertions(+), 27 deletions(-) rename src/bin/{rust_python_linter.rs => ruff.rs} (91%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 149a3b9cfe..d6170d3877 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,7 +27,7 @@ jobs: ${{ runner.os }}-build-${{ env.cache-name }}- ${{ runner.os }}-build- ${{ runner.os }}- - - run: cargo build --bin rust_python_linter --release + - run: cargo build --release cargo_fmt: name: "cargo fmt" diff --git a/.gitignore b/.gitignore index 9a7b7b5981..1ac9ebd0c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ # Local cache .cache -!resources/test/src -resources/test +resources/test/cpython ### # Rust.gitignore diff --git a/Cargo.lock b/Cargo.lock index 5cb90877cd..b71c08f41e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1699,7 +1699,7 @@ dependencies = [ ] [[package]] -name = "rust-python-linter" +name = "ruff" version = "0.0.13" dependencies = [ "anyhow", diff --git a/Cargo.toml b/Cargo.toml index a603a793bd..c7122f09f0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "rust-python-linter" +name = "ruff" version = "0.0.13" edition = "2021" [lib] -name = "rust_python_linter" +name = "ruff" crate-type = ["cdylib", "lib"] [dependencies] diff --git a/README.md b/README.md index 2d5c9569a0..e5f43a5f1c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# rust-python-linter +# ruff A performance-focused, [Pyflakes](https://github.com/PyCQA/pyflakes)-inspired Python linter, written in Rust. @@ -12,10 +12,10 @@ Features: ## Installation -Available as [`rust-python-linter`](https://pypi.org/project/rust-python-linter/) on PyPI: +Available as [`ruff`](https://pypi.org/project/ruff/) on PyPI: ```shell -pip install rust-python-linter +pip install ruff ``` ## Usage @@ -23,22 +23,22 @@ pip install rust-python-linter To run the linter, try any of the following: ```shell -rust_python_linter path/to/code/to/check.py +ruff path/to/code/to/check.py # ...or... -rust_python_linter path/to/code/ +ruff path/to/code/ # ...or... -rust_python_linter path/to/code/*.py +ruff path/to/code/*.py ``` You can also run in `--watch` mode to automatically re-run the linter on-change with, e.g.: ```shell -rust_python_linter path/to/code/ --watch +ruff path/to/code/ --watch ``` ## Development -As the name suggests, `rust-python-linter` is implemented in Rust: +`ruff` is written in Rust: ```shell cargo fmt @@ -48,7 +48,7 @@ cargo run resources/test/src ## Deployment -`rust-python-linter` is released for Python using [`maturin`](https://github.com/PyO3/maturin): +`ruff` is released for Python using [`maturin`](https://github.com/PyO3/maturin): ```shell maturin publish --skip-existing --target x86_64-apple-darwin @@ -125,14 +125,14 @@ Next, to benchmark the release build: cargo build --release hyperfine --warmup 5 \ - "./target/release/rust_python_linter ./resources/test/cpython/ --no-cache" \ - "./target/release/rust_python_linter ./resources/test/cpython/" + "./target/release/ruff ./resources/test/cpython/ --no-cache" \ + "./target/release/ruff ./resources/test/cpython/" -Benchmark 1: ./target/release/rust_python_linter ./resources/test/cpython/ --no-cache +Benchmark 1: ./target/release/ruff ./resources/test/cpython/ --no-cache Time (mean ± σ): 353.6 ms ± 7.6 ms [User: 2868.8 ms, System: 171.5 ms] Range (min … max): 344.4 ms … 367.3 ms 10 runs -Benchmark 2: ./target/release/rust_python_linter ./resources/test/cpython/ +Benchmark 2: ./target/release/ruff ./resources/test/cpython/ Time (mean ± σ): 59.6 ms ± 2.5 ms [User: 36.4 ms, System: 345.6 ms] Range (min … max): 55.9 ms … 67.0 ms 48 runs ``` diff --git a/src/bin/rust_python_linter.rs b/src/bin/ruff.rs similarity index 91% rename from src/bin/rust_python_linter.rs rename to src/bin/ruff.rs index f2d91c6386..08b13788f0 100644 --- a/src/bin/rust_python_linter.rs +++ b/src/bin/ruff.rs @@ -11,16 +11,16 @@ use notify::{raw_watcher, RecursiveMode, Watcher}; use rayon::prelude::*; use walkdir::DirEntry; -use ::rust_python_linter::fs::iter_python_files; -use ::rust_python_linter::linter::check_path; -use ::rust_python_linter::logging::set_up_logging; -use ::rust_python_linter::message::Message; -use ::rust_python_linter::tell_user; -use rust_python_linter::settings::Settings; +use ::ruff::fs::iter_python_files; +use ::ruff::linter::check_path; +use ::ruff::logging::set_up_logging; +use ::ruff::message::Message; +use ::ruff::settings::Settings; +use ::ruff::tell_user; #[derive(Debug, Parser)] -#[clap(name = "rust-python-linter")] -#[clap(about = "A bare-bones Python linter written in Rust", long_about = None)] +#[clap(name = "ruff")] +#[clap(about = "A Python linter written in Rust", long_about = None)] struct Cli { #[clap(parse(from_os_str), value_hint = ValueHint::AnyPath, required = true)] files: Vec,