Skip to content

Commit 8590bc2

Browse files
committed
pre-commit: switch to Ruff
Drop blacken-docs; it doesn't appear to work and I'm not sure if it ever did. Ruff can't yet replace it, but it's easier not to use two different formatters in the same repo. Signed-off-by: Benjamin Gilbert <bgilbert@cs.cmu.edu>
1 parent 7ba6e90 commit 8590bc2

4 files changed

Lines changed: 19 additions & 54 deletions

File tree

.github/maintainer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
## Maintainer issue templates
44

55
- [Release checklist](https://github.com/openslide/openslide-python/issues/new?title=Release+X.Y.Z&body=%23+OpenSlide+Python+release+process%0A%0A-+%5B+%5D+Update+%60CHANGELOG.md%60+and+version+in+%60openslide%2F_version.py%60%0A-+%5B+%5D+Create+and+push+signed+tag%0A-+%5B+%5D+Find+the+%5Bworkflow+run%5D%28https%3A%2F%2Fgithub.com%2Fopenslide%2Fopenslide-python%2Factions%2Fworkflows%2Fpython.yml%29+for+the+tag%0A++-+%5B+%5D+Once+the+build+finishes%2C+approve+deployment+to+PyPI%0A++-+%5B+%5D+Download+the+docs+artifact%0A-+%5B+%5D+Verify+that+the+workflow+created+a+%5BPyPI+release%5D%28https%3A%2F%2Fpypi.org%2Fp%2Fopenslide-python%29+with+a+description%2C+source+tarball%2C+and+wheels%0A-+%5B+%5D+Verify+that+the+workflow+created+a+%5BGitHub+release%5D%28https%3A%2F%2Fgithub.com%2Fopenslide%2Fopenslide-python%2Freleases%29+with+release+notes%2C+source+tarballs%2C+and+wheels%0A-+%5B+%5D+%60cd%60+into+website+checkout%3B+%60rm+-r+api%2Fpython+%26%26+unzip+%2Fpath%2Fto%2Fdownloaded%2Fopenslide-python-docs.zip+%26%26+mv+openslide-python-docs-%2A+api%2Fpython%60%0A-+%5B+%5D+Update+website%3A+%60_data%2Freleases.yaml%60%2C+%60_includes%2Fnews.md%60%0A-+%5B+%5D+Start+a+%5BCI+build%5D%28https%3A%2F%2Fgithub.com%2Fopenslide%2Fopenslide.github.io%2Factions%2Fworkflows%2Fretile.yml%29+of+the+demo+site%0A-+%5B+%5D+Update+Ubuntu+PPA%0A-+%5B+%5D+Update+Fedora+and+possibly+EPEL+packages%0A-+%5B+%5D+Check+that+%5BCopr+package%5D%28https%3A%2F%2Fcopr.fedorainfracloud.org%2Fcoprs%2Fg%2Fopenslide%2Fopenslide%2Fbuilds%2F%29+built+successfully%0A-+%5B+%5D+Send+mail+to+-announce+and+-users%0A-+%5B+%5D+Post+to+%5Bforum.image.sc%5D%28https%3A%2F%2Fforum.image.sc%2Fc%2Fannouncements%2F10%29%0A-+%5B+%5D+Update+MacPorts+package&labels=release)
6-
- [Update checklist for a Python minor release](https://github.com/openslide/openslide-python/issues/new?title=Add+Python+X.Y&body=%23+Adding+a+new+Python+release%0A%0A-+Update+Git+main%0A++-+%5B+%5D+%60git+checkout+main%60%0A++-+%5B+%5D+In+%60pyproject.toml%60%2C+add+classifier+for+new+Python+version+and+update+%60tool.black.target-version%60%0A++-+%5B+%5D+In+%60.github%2Fworkflows%2Fpython.yml%60%2C+update+hardcoded+Python+versions+and+add+new+version+to+lists%0A++-+%5B+%5D+Commit+and+open+a+PR%0A++-+%5B+%5D+Merge+the+PR+when+CI+passes%0A++-+%5B+%5D+Add+new+Python+jobs+to+%5Bbranch+protection+required+checks%5D%28https%3A%2F%2Fgithub.com%2Fopenslide%2Fopenslide-python%2Fsettings%2Fbranches%29%0A-+%5B+%5D+Update+MacPorts+package%0A-+%5B+%5D+Update+website%3A+Python+3+versions+in+%60download%2Findex.md%60&labels=release)
6+
- [Update checklist for a Python minor release](https://github.com/openslide/openslide-python/issues/new?title=Add+Python+X.Y&body=%23+Adding+a+new+Python+release%0A%0A-+Update+Git+main%0A++-+%5B+%5D+%60git+checkout+main%60%0A++-+%5B+%5D+In+%60pyproject.toml%60%2C+add+classifier+for+new+Python+version%0A++-+%5B+%5D+In+%60.github%2Fworkflows%2Fpython.yml%60%2C+update+hardcoded+Python+versions+and+add+new+version+to+lists%0A++-+%5B+%5D+Commit+and+open+a+PR%0A++-+%5B+%5D+Merge+the+PR+when+CI+passes%0A++-+%5B+%5D+Add+new+Python+jobs+to+%5Bbranch+protection+required+checks%5D%28https%3A%2F%2Fgithub.com%2Fopenslide%2Fopenslide-python%2Fsettings%2Fbranches%29%0A-+%5B+%5D+Update+MacPorts+package%0A-+%5B+%5D+Update+website%3A+Python+3+versions+in+%60download%2Findex.md%60&labels=release)

.github/maintainer/update-python.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ labels: [release]
99

1010
- Update Git main
1111
- [ ] `git checkout main`
12-
- [ ] In `pyproject.toml`, add classifier for new Python version and update `tool.black.target-version`
12+
- [ ] In `pyproject.toml`, add classifier for new Python version
1313
- [ ] In `.github/workflows/python.yml`, update hardcoded Python versions and add new version to lists
1414
- [ ] Commit and open a PR
1515
- [ ] Merge the PR when CI passes

.pre-commit-config.yaml

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,13 @@ repos:
1515
- id: mixed-line-ending
1616
- id: trailing-whitespace
1717

18-
- repo: https://github.com/asottile/pyupgrade
19-
rev: v3.21.2
18+
- repo: https://github.com/astral-sh/ruff-pre-commit
19+
rev: v0.15.10
2020
hooks:
21-
- id: pyupgrade
22-
name: Modernize python code
23-
args: ["--py310-plus"]
24-
25-
- repo: https://github.com/PyCQA/isort
26-
rev: 8.0.1
27-
hooks:
28-
- id: isort
29-
name: Reorder python imports with isort
30-
31-
- repo: https://github.com/psf/black
32-
rev: 26.3.1
33-
hooks:
34-
- id: black
35-
name: Format python code with black
36-
37-
- repo: https://github.com/asottile/blacken-docs
38-
rev: 1.20.0
39-
hooks:
40-
- id: blacken-docs
41-
name: Format python code in documentation
42-
43-
- repo: https://github.com/asottile/yesqa
44-
rev: v1.5.0
45-
hooks:
46-
- id: yesqa
47-
additional_dependencies: [flake8-bugbear, Flake8-pyproject]
48-
49-
- repo: https://github.com/PyCQA/flake8
50-
rev: 7.3.0
51-
hooks:
52-
- id: flake8
53-
name: Lint python code with flake8
54-
additional_dependencies: [flake8-bugbear, Flake8-pyproject]
21+
- id: ruff-check
22+
types_or: [python, pyi, pyproject]
23+
args: [--fix]
24+
- id: ruff-format
5525

5626
- repo: https://github.com/pre-commit/mirrors-mypy
5727
rev: v1.20.0

pyproject.toml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,12 @@ version = {attr = "openslide._version.__version__"}
5050
[tool.setuptools.package-data]
5151
openslide = ["py.typed", "*.pyi"]
5252

53-
[tool.black]
54-
skip-string-normalization = true
55-
target-version = ["py310", "py311", "py312", "py313", "py314"]
56-
5753
# Ref: https://github.com/codespell-project/codespell#using-a-config-file
5854
[tool.codespell]
5955
check-hidden = true
6056
# ignore-regex = ""
6157
# ignore-words-list = ""
6258

63-
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#flake8
64-
# also ignore:
65-
# - E741 ambiguous variable name
66-
# requires Flake8-pyproject
67-
[tool.flake8]
68-
max-line-length = 88
69-
extend-ignore = ["E203", "E741"]
70-
71-
[tool.isort]
72-
profile = "black"
73-
force_sort_within_sections = true
74-
7559
[tool.mypy]
7660
python_version = "3.10"
7761
strict = true
@@ -87,6 +71,17 @@ pythonpath = "tests"
8771
[tool.rstcheck]
8872
ignore_messages = "(Hyperlink target \".*\" is not referenced\\.$)"
8973

74+
[tool.ruff.format]
75+
quote-style = "single"
76+
77+
[tool.ruff.lint]
78+
extend-select = ["B", "C4", "FLY", "I", "RUF", "UP"]
79+
# ambiguous-variable-name
80+
ignore = ["E741"]
81+
82+
[tool.ruff.lint.isort]
83+
force-sort-within-sections = true
84+
9085
[build-system]
9186
requires = ["setuptools >= 77.0.0"]
9287
build-backend = "setuptools.build_meta"

0 commit comments

Comments
 (0)