-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Ruff](https://docs.astral.sh/ruff/): An extremely fast Python linter and code formatter, written in Rust. Replaces existing Black hook. Runs on pre-commit (contributors should run `pre-commit install` in the repo root to set this up.)
- Loading branch information
Showing
3 changed files
with
42 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env python3 | ||
import subprocess | ||
import sys | ||
|
||
filez = sys.argv[1:] | ||
|
||
print("Running ruff linter") | ||
# TODO: should we enable `--unsafe-fixes` here? | ||
# (Most of the 'unsafe' fixes appear to be "it might move a comment slightly" level of unsafe) | ||
subprocess.check_call(["ruff", "check", "--fix", *filez]) | ||
|
||
print("Running ruff formatter") | ||
subprocess.check_call(["ruff", "format", *filez]) | ||
|
||
# pre-commit doesn't add changed files to the index. Normally changed files fail the hook. | ||
# however, just calling git add sneakily works around that. | ||
subprocess.check_call(["git", "add"] + filez) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,21 @@ | ||
[tool.black] | ||
target-version = ['py37'] | ||
|
||
[tool.pyright] | ||
exclude = ["**/__pycache__", "**/build", "venv"] | ||
|
||
|
||
[tool.ruff] | ||
line-length = 88 | ||
target-version = "py310" | ||
force-exclude = true | ||
|
||
[tool.ruff.lint] | ||
preview = true | ||
select = [ | ||
"F402", | ||
"F404", | ||
"F823", | ||
"F821", | ||
"F822", | ||
"E112", | ||
"E113", | ||
"E902", | ||
] |