Skip to content

Commit 0660886

Browse files
authored
Merge pull request #6966 from akx/ruff
2 parents 4a7cf05 + 9e615b6 commit 0660886

File tree

17 files changed

+57
-52
lines changed

17 files changed

+57
-52
lines changed

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ indent_style = space
1313

1414
trim_trailing_whitespace = true
1515

16-
[*.yml]
16+
[*.{toml,yml}]
1717
# Two-space indentation
1818
indent_size = 2
1919

.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 .

Tests/bench_cffi_access.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def test_direct():
4545

4646
assert caccess[(0, 0)] == access[(0, 0)]
4747

48-
print("Size: %sx%s" % im.size)
48+
print("Size: %sx%s" % im.size) # noqa: UP031
4949
timer(iterate_get, "PyAccess - get", im.size, access)
5050
timer(iterate_set, "PyAccess - set", im.size, access)
5151
timer(iterate_get, "C-api - get", im.size, caccess)

_custom_build/backend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import sys
22

3-
from setuptools.build_meta import * # noqa: F401, F403
3+
from setuptools.build_meta import * # noqa: F403
44
from setuptools.build_meta import build_wheel
55

66
backend_class = build_wheel.__self__.__class__

docs/conf.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,14 @@ def setup(app):
318318

319319

320320
linkcheck_allowed_redirects = {
321-
r"https://www.bestpractices.dev/projects/6331": r"https://www.bestpractices.dev/en/.*", # noqa: E501
322-
r"https://badges.gitter.im/python-pillow/Pillow.svg": r"https://badges.gitter.im/repo.svg", # noqa: E501
323-
r"https://gitter.im/python-pillow/Pillow?.*": r"https://app.gitter.im/#/room/#python-pillow_Pillow:gitter.im?.*", # noqa: E501
324-
r"https://pillow.readthedocs.io/?badge=latest": r"https://pillow.readthedocs.io/en/stable/?badge=latest", # noqa: E501
321+
r"https://www.bestpractices.dev/projects/6331": r"https://www.bestpractices.dev/en/.*",
322+
r"https://badges.gitter.im/python-pillow/Pillow.svg": r"https://badges.gitter.im/repo.svg",
323+
r"https://gitter.im/python-pillow/Pillow?.*": r"https://app.gitter.im/#/room/#python-pillow_Pillow:gitter.im?.*",
324+
r"https://pillow.readthedocs.io/?badge=latest": r"https://pillow.readthedocs.io/en/stable/?badge=latest",
325325
r"https://pillow.readthedocs.io": r"https://pillow.readthedocs.io/en/stable/",
326-
r"https://tidelift.com/badges/package/pypi/Pillow?.*": r"https://img.shields.io/badge/.*", # noqa: E501
327-
r"https://zenodo.org/badge/17549/python-pillow/Pillow.svg": r"https://zenodo.org/badge/doi/[\.0-9]+/zenodo.[0-9]+.svg", # noqa: E501
328-
r"https://zenodo.org/badge/latestdoi/17549/python-pillow/Pillow": r"https://zenodo.org/record/[0-9]+", # noqa: E501
326+
r"https://tidelift.com/badges/package/pypi/Pillow?.*": r"https://img.shields.io/badge/.*",
327+
r"https://zenodo.org/badge/17549/python-pillow/Pillow.svg": r"https://zenodo.org/badge/doi/[\.0-9]+/zenodo.[0-9]+.svg",
328+
r"https://zenodo.org/badge/latestdoi/17549/python-pillow/Pillow": r"https://zenodo.org/record/[0-9]+",
329329
}
330330

331331
# sphinx.ext.extlinks

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"

src/PIL/EpsImagePlugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def Ghostscript(tile, size, fp, scale=1, transparency=False):
122122
gs_binary,
123123
"-q", # quiet mode
124124
"-g%dx%d" % size, # set output geometry (pixels)
125-
"-r%fx%f" % res, # set input DPI (dots per inch)
125+
"-r%fx%f" % res, # set input DPI (dots per inch) # noqa: UP031
126126
"-dBATCH", # exit after processing
127127
"-dNOPAUSE", # don't pause between pages
128128
"-dSAFER", # safe mode

0 commit comments

Comments
 (0)