Skip to content

Commit 3fb21c4

Browse files
authored
chore: move to using Ruff (#85)
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
1 parent 32da025 commit 3fb21c4

File tree

6 files changed

+61
-7
lines changed

6 files changed

+61
-7
lines changed

.pre-commit-config.yaml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,20 @@ repos:
3333
- id: requirements-txt-fixer
3434
- id: trailing-whitespace
3535

36-
# Runs Black, pyupgrade, isort, autoflake, blacken-docs
37-
- repo: https://github.com/Zac-HD/shed
38-
rev: 2023.3.1
36+
# Black, the code formatter, natively supports pre-commit
37+
- repo: https://github.com/psf/black
38+
rev: 23.3.0
3939
hooks:
40-
- id: shed
40+
- id: black
4141
exclude: ^(docs)
4242

43+
# Check linting and style issues
44+
- repo: https://github.com/charliermarsh/ruff-pre-commit
45+
rev: "v0.0.263"
46+
hooks:
47+
- id: ruff
48+
args: ["--fix", "--show-fixes"]
49+
4350
# Changes tabs to spaces
4451
- repo: https://github.com/Lucas-C/pre-commit-hooks
4552
rev: v1.5.1

docs/conf.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
#
1111
# All configuration values have a default; values that are commented out
1212
# serve to show the default.
13-
14-
import os
15-
import sys
13+
from __future__ import annotations
1614

1715
# If extensions (or modules to document with autodoc) are in another directory,
1816
# add these directories to sys.path here. If the directory is relative to the

noxfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import nox
24

35
nox.options.sessions = ["lint", "tests"]

pyproject.toml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,46 @@ test-command = "pytest {project}/tests"
4444
test-extras = ["test"]
4545
test-skip = ["*universal2:arm64"]
4646
build-verbosity = 1
47+
48+
49+
[tool.ruff]
50+
select = [
51+
"E", "F", "W", # flake8
52+
"B", # flake8-bugbear
53+
"I", # isort
54+
"ARG", # flake8-unused-arguments
55+
"C4", # flake8-comprehensions
56+
"EM", # flake8-errmsg
57+
"ICN", # flake8-import-conventions
58+
"ISC", # flake8-implicit-str-concat
59+
"G", # flake8-logging-format
60+
"PGH", # pygrep-hooks
61+
"PIE", # flake8-pie
62+
"PL", # pylint
63+
"PT", # flake8-pytest-style
64+
"PTH", # flake8-use-pathlib
65+
"RET", # flake8-return
66+
"RUF", # Ruff-specific
67+
"SIM", # flake8-simplify
68+
"T20", # flake8-print
69+
"UP", # pyupgrade
70+
"YTT", # flake8-2020
71+
"EXE", # flake8-executable
72+
"NPY", # NumPy specific rules
73+
"PD", # pandas-vet
74+
]
75+
extend-ignore = [
76+
"PLR", # Design related pylint codes
77+
"E501", # Line too long
78+
]
79+
target-version = "py37"
80+
src = ["src"]
81+
unfixable = [
82+
"T20", # Removes print statements
83+
"F841", # Removes unused variables
84+
]
85+
flake8-unused-arguments.ignore-variadic-names = true
86+
isort.required-imports = ["from __future__ import annotations"]
87+
88+
[tool.ruff.per-file-ignores]
89+
"tests/**" = ["T20"]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
from ._core import __doc__, __version__, add, subtract
24

35
__all__ = ["__doc__", "__version__", "add", "subtract"]

tests/test_basic.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from __future__ import annotations
2+
13
import scikit_build_example as m
24

35

0 commit comments

Comments
 (0)