Skip to content

Commit de6c4b0

Browse files
akxradarherehugovk
committed
Switch linting to ruff
Co-authored-by: Andrew Murray <[email protected]> Co-authored-by: Hugo van Kemenade <[email protected]>
1 parent 80406a7 commit de6c4b0

File tree

5 files changed

+36
-30
lines changed

5 files changed

+36
-30
lines changed

.flake8

Lines changed: 0 additions & 3 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,32 @@
11
repos:
2-
- repo: https://github.com/asottile/pyupgrade
3-
rev: v3.13.0
2+
- repo: https://github.com/astral-sh/ruff-pre-commit
3+
rev: v0.1.4
44
hooks:
5-
- id: pyupgrade
6-
args: [--py38-plus]
5+
- id: ruff
6+
args: [--fix, --exit-non-zero-on-fix]
77

88
- repo: https://github.com/psf/black-pre-commit-mirror
99
rev: 23.9.1
1010
hooks:
1111
- id: black
1212
args: [--target-version=py38]
1313

14-
- repo: https://github.com/PyCQA/isort
15-
rev: 5.12.0
16-
hooks:
17-
- id: isort
18-
1914
- repo: https://github.com/PyCQA/bandit
2015
rev: 1.7.5
2116
hooks:
2217
- id: bandit
2318
args: [--severity-level=high]
2419
files: ^src/
2520

26-
- repo: https://github.com/asottile/yesqa
27-
rev: v1.5.0
28-
hooks:
29-
- id: yesqa
30-
3121
- repo: https://github.com/Lucas-C/pre-commit-hooks
3222
rev: v1.5.4
3323
hooks:
3424
- id: remove-tabs
3525
exclude: (Makefile$|\.bat$|\.cmake$|\.eps$|\.fits$|\.gd$|\.opt$)
3626

37-
- repo: https://github.com/PyCQA/flake8
38-
rev: 6.1.0
39-
hooks:
40-
- id: flake8
41-
additional_dependencies:
42-
[flake8-2020, flake8-errmsg, flake8-implicit-str-concat, flake8-logging]
43-
4427
- repo: https://github.com/pre-commit/pygrep-hooks
4528
rev: v1.10.0
4629
hooks:
47-
- id: python-check-blanket-noqa
4830
- id: rst-backticks
4931

5032
- repo: https://github.com/pre-commit/pre-commit-hooks

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ include *.md
55
include *.py
66
include *.rst
77
include *.sh
8+
include *.toml
89
include *.txt
910
include *.yaml
1011
include .flake8

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ help:
4949
@echo " install make and install"
5050
@echo " install-coverage make and install with C coverage"
5151
@echo " lint run the lint checks"
52-
@echo " lint-fix run Black and isort to (mostly) fix lint issues"
52+
@echo " lint-fix run Ruff to (mostly) fix lint issues"
5353
@echo " release-test run code and package tests before release"
5454
@echo " test run tests on installed Pillow"
5555

@@ -118,6 +118,6 @@ lint:
118118
.PHONY: lint-fix
119119
lint-fix:
120120
python3 -c "import black" > /dev/null 2>&1 || python3 -m pip install black
121-
python3 -c "import isort" > /dev/null 2>&1 || python3 -m pip install isort
122121
python3 -m black --target-version py38 .
123-
python3 -m isort .
122+
python3 -c "import ruff" > /dev/null 2>&1 || python3 -m pip install ruff
123+
python3 -m ruff --fix .

pyproject.toml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,34 @@ package-dir = {"" = "src"}
7777
[tool.setuptools.dynamic]
7878
version = {attr = "PIL.__version__"}
7979

80-
[tool.isort]
81-
profile = "black"
80+
[tool.ruff]
81+
target-version = "py38"
82+
line-length = 88
83+
select = [
84+
"E", # pycodestyle errors
85+
"EM", # flake8-errmsg
86+
"F", # pyflakes errors
87+
"I", # isort
88+
"ISC", # flake8-implicit-str-concat
89+
"PGH", # pygrep-hooks
90+
"RUF100", # unused noqa (yesqa)
91+
"UP", # pyupgrade
92+
"W", # pycodestyle warnings
93+
"YTT", # flake8-2020
94+
# "LOG", # TODO: enable flake8-logging when it's not in preview anymore
95+
]
96+
extend-ignore = [
97+
"E203", # Whitespace before ':'
98+
"E221", # Multiple spaces before operator
99+
"E226", # Missing whitespace around arithmetic operator
100+
"E241", # Multiple spaces after ','
101+
]
102+
103+
[tool.ruff.per-file-ignores]
104+
"Tests/*.py" = ["I001"]
105+
106+
[tool.ruff.isort]
107+
known-first-party = ["PIL"]
82108

83109
[tool.pytest.ini_options]
84110
addopts = "-ra --color=yes"

0 commit comments

Comments
 (0)