Skip to content

Commit

Permalink
Switch linting to ruff
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Murray <[email protected]>
Co-authored-by: Hugo van Kemenade <[email protected]>
  • Loading branch information
3 people committed Oct 30, 2023
1 parent bbad71f commit 16a5895
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 27 deletions.
26 changes: 4 additions & 22 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,50 +1,32 @@
repos:
- repo: https://github.com/asottile/pyupgrade
rev: v3.13.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.2
hooks:
- id: pyupgrade
args: [--py38-plus]
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

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

- repo: https://github.com/PyCQA/isort
rev: 5.12.0
hooks:
- id: isort

- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
args: [--severity-level=high]
files: ^src/

- repo: https://github.com/asottile/yesqa
rev: v1.5.0
hooks:
- id: yesqa

- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
hooks:
- id: remove-tabs
exclude: (Makefile$|\.bat$|\.cmake$|\.eps$|\.fits$|\.gd$|\.opt$)

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
hooks:
- id: flake8
additional_dependencies:
[flake8-2020, flake8-errmsg, flake8-implicit-str-concat, flake8-logging]

- repo: https://github.com/pre-commit/pygrep-hooks
rev: v1.10.0
hooks:
- id: python-check-blanket-noqa
- id: rst-backticks

- repo: https://github.com/pre-commit/pre-commit-hooks
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ include *.md
include *.py
include *.rst
include *.sh
include *.toml
include *.txt
include *.yaml
include .flake8
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ help:
@echo " install make and install"
@echo " install-coverage make and install with C coverage"
@echo " lint run the lint checks"
@echo " lint-fix run Black and isort to (mostly) fix lint issues"
@echo " lint-fix run Ruff to (mostly) fix lint issues"
@echo " release-test run code and package tests before release"
@echo " test run tests on installed Pillow"

Expand Down Expand Up @@ -118,6 +118,6 @@ lint:
.PHONY: lint-fix
lint-fix:
python3 -c "import black" > /dev/null 2>&1 || python3 -m pip install black
python3 -c "import isort" > /dev/null 2>&1 || python3 -m pip install isort
python3 -m black --target-version py38 .
python3 -m isort .
python3 -c "import ruff" > /dev/null 2>&1 || python3 -m pip install ruff
python3 -m ruff --fix .
23 changes: 21 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,27 @@ package-dir = {"" = "src"}
[tool.setuptools.dynamic]
version = {attr = "PIL.__version__"}

[tool.isort]
profile = "black"
[tool.ruff]
target-version = "py38"
line-length = 88
select = [
"E", # pycodestyle errors
"EM", # flake8-errmsg
"F", # pyflakes errors
"I", # isort
"ISC", # flake8-implicit-str-concat
"PGH", # pygrep-hooks
"RUF100", # unused noqa (yesqa)
"UP", # pyupgrade
"W", # pycodestyle warnings
"YTT", # flake8-2020
]

[tool.ruff.per-file-ignores]
"Tests/*.py" = ["I001"]

[tool.ruff.isort]
known-first-party = ["PIL"]

[tool.pytest.ini_options]
addopts = "-ra --color=yes"
Expand Down
67 changes: 67 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[metadata]
name = Pillow
description = Python Imaging Library (Fork)
long_description = file: README.md
long_description_content_type = text/markdown
url = https://python-pillow.org
author = Jeffrey A. Clark (Alex)
author_email = [email protected]
license = HPND
classifiers =
Development Status :: 6 - Mature
License :: OSI Approved :: Historical Permission Notice and Disclaimer (HPND)
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: Implementation :: CPython
Programming Language :: Python :: Implementation :: PyPy
Topic :: Multimedia :: Graphics
Topic :: Multimedia :: Graphics :: Capture :: Digital Camera
Topic :: Multimedia :: Graphics :: Capture :: Screen Capture
Topic :: Multimedia :: Graphics :: Graphics Conversion
Topic :: Multimedia :: Graphics :: Viewers
keywords = Imaging
project_urls =
Documentation=https://pillow.readthedocs.io
Source=https://github.com/python-pillow/Pillow
Funding=https://tidelift.com/subscription/pkg/pypi-pillow?utm_source=pypi-pillow&utm_medium=pypi
Release notes=https://pillow.readthedocs.io/en/stable/releasenotes/index.html
Changelog=https://github.com/python-pillow/Pillow/blob/main/CHANGES.rst
Twitter=https://twitter.com/PythonPillow
Mastodon=https://fosstodon.org/@pillow

[options]
packages = PIL
python_requires = >=3.8
include_package_data = True
package_dir =
= src

[options.extras_require]
docs =
furo
olefile
sphinx>=2.4
sphinx-copybutton
sphinx-inline-tabs
sphinx-removed-in
sphinxext-opengraph
tests =
check-manifest
coverage
defusedxml
markdown2
olefile
packaging
pyroma
pytest
pytest-cov
pytest-timeout

[tool:pytest]
addopts = -ra --color=yes
testpaths = Tests

0 comments on commit 16a5895

Please sign in to comment.