ruff/python/ruff-ecosystem
Zanie Blue f18e7d40ac
Add internal hidden rules for testing (#9747)
Updated implementation of https://github.com/astral-sh/ruff/pull/7369
which was left out in the cold.

This was motivated again following changes in #9691 and #9689 where we
could not test the changes without actually deprecating or removing
rules.

---

Follow-up to discussion in https://github.com/astral-sh/ruff/pull/7210

Moves integration tests from using rules that are transitively in
nursery / preview groups to dedicated test rules that only exist during
development. These rules always raise violations (they do not require
specific file behavior). The rules are not available in production or in
the documentation.

Uses features instead of `cfg(test)` for cross-crate support per
https://github.com/rust-lang/cargo/issues/8379
2024-02-01 08:44:51 -06:00
..
ruff_ecosystem Add internal hidden rules for testing (#9747) 2024-02-01 08:44:51 -06:00
pyproject.toml Allow config-file overrides in ecosystem checks (#9286) 2023-12-28 10:44:50 -06:00
README.md Add support for ruff-ecosystem format comparisons with black (#8419) 2023-11-02 01:29:25 +00:00

ruff-ecosystem

Compare lint and format results for two different ruff versions (e.g. main and a PR) on real world projects.

Installation

From the Ruff project root, install with pip:

pip install -e ./python/ruff-ecosystem

Usage

ruff-ecosystem <check | format> <baseline executable> <comparison executable>

Note executable paths may be absolute, relative to the current working directory, or will be looked up in the current Python environment and PATH.

Run ruff check ecosystem checks comparing your debug build to your system Ruff:

ruff-ecosystem check ruff "./target/debug/ruff"

Run ruff format ecosystem checks comparing your debug build to your system Ruff:

ruff-ecosystem format ruff "./target/debug/ruff"

Run ruff format ecosystem checks comparing with changes to code that is already formatted:

ruff-ecosystem format ruff "./target/debug/ruff" --format-comparison ruff-then-ruff

Run ruff format ecosystem checks comparing with the Black formatter:

ruff-ecosystem format black ruff -v --cache python/checkouts --format-comparison black-and-ruff

The default output format is markdown, which includes nice summaries of the changes. You can use --output-format json to display the raw data — this is particularly useful when making changes to the ecosystem checks.

Development

When developing, it can be useful to set the --pdb flag to drop into a debugger on failure:

ruff-ecosystem check ruff "./target/debug/ruff" --pdb

You can also provide a path to cache checkouts to speed up repeated runs:

ruff-ecosystem check ruff "./target/debug/ruff" --cache ./repos