Skip to content

Commit 57ab0ac

Browse files
committed
ci!: Add ruff, replacing isort, black, flake8 and its plugins
See also: - https://ruff.rs/ - https://beta.ruff.rs/ - https://github.com/charliermarsh/ruff
1 parent ee67c82 commit 57ab0ac

File tree

6 files changed

+132
-334
lines changed

6 files changed

+132
-334
lines changed

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,16 @@ jobs:
2525

2626
- name: Install dependencies
2727
run: |
28-
poetry install -E "docs test coverage lint format"
28+
poetry install -E "docs test coverage lint"
2929
poetry run pip install docutils~=${{ matrix.docutils-version }}
3030
3131
- name: Print python versions
3232
run: |
3333
python -V
3434
poetry run python -V
3535
36-
- name: Lint with flake8
37-
run: poetry run flake8
36+
- name: Lint with ruff
37+
run: poetry run ruff .
3838

3939
- name: Lint with mypy
4040
run: poetry run mypy .

Makefile

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ entr_warn:
1212
@echo "See https://eradman.com/entrproject/ "
1313
@echo "----------------------------------------------------------"
1414

15-
isort:
16-
poetry run isort `${PY_FILES}`
17-
18-
black:
19-
poetry run black `${PY_FILES}`
20-
2115
test:
2216
poetry run py.test $(test)
2317

@@ -36,11 +30,11 @@ start_docs:
3630
design_docs:
3731
$(MAKE) -C docs design
3832

39-
flake8:
40-
flake8
33+
ruff:
34+
ruff .
4135

42-
watch_flake8:
43-
if command -v entr > /dev/null; then ${PY_FILES} | entr -c $(MAKE) flake8; else $(MAKE) flake8 entr_warn; fi
36+
watch_ruff:
37+
if command -v entr > /dev/null; then ${PY_FILES} | entr -c $(MAKE) ruff; else $(MAKE) ruff entr_warn; fi
4438

4539
mypy:
4640
poetry run mypy `${PY_FILES}`

docs/developing.md

Lines changed: 93 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
`cd gp-libs`
88

9-
`poetry install -E "docs test coverage lint format"`
9+
`poetry install -E "docs test coverage lint"`
1010

1111
Makefile commands prefixed with `watch_` will watch files and rerun.
1212

@@ -48,11 +48,96 @@ Rebuild docs and run server via one terminal: `make dev_docs` (requires above, a
4848

4949
## Formatting / Linting
5050

51-
The project uses [black] and [isort] (one after the other) and runs [flake8] via
52-
CI. See the configuration in `pyproject.toml` and `setup.cfg`:
51+
### ruff
5352

54-
`make black isort`: Run `black` first, then `isort` to handle import nuances
55-
`make flake8`, to watch (requires `entr(1)`): `make watch_flake8`
53+
The project uses [ruff] to handles formatting, sorting imports and linting.
54+
55+
````{tab} Command
56+
57+
poetry:
58+
59+
```console
60+
$ poetry run ruff
61+
```
62+
63+
If you setup manually:
64+
65+
```console
66+
$ ruff .
67+
```
68+
69+
````
70+
71+
````{tab} make
72+
73+
```console
74+
$ make ruff
75+
```
76+
77+
````
78+
79+
````{tab} Watch
80+
81+
```console
82+
$ make watch_ruff
83+
```
84+
85+
requires [`entr(1)`].
86+
87+
````
88+
89+
````{tab} Fix files
90+
91+
poetry:
92+
93+
```console
94+
$ poetry run ruff . --fix
95+
```
96+
97+
If you setup manually:
98+
99+
```console
100+
$ ruff . --fix
101+
```
102+
103+
````
104+
105+
### mypy
106+
107+
[mypy] is used for static type checking.
108+
109+
````{tab} Command
110+
111+
poetry:
112+
113+
```console
114+
$ poetry run mypy .
115+
```
116+
117+
If you setup manually:
118+
119+
```console
120+
$ mypy .
121+
```
122+
123+
````
124+
125+
````{tab} make
126+
127+
```console
128+
$ make mypy
129+
```
130+
131+
````
132+
133+
````{tab} Watch
134+
135+
```console
136+
$ make watch_mypy
137+
```
138+
139+
requires [`entr(1)`].
140+
````
56141

57142
## Releasing
58143

@@ -70,6 +155,6 @@ Update `__version__` in `src/gp_libs.py` and `pyproject.toml`::
70155

71156
[poetry]: https://python-poetry.org/
72157
[entr(1)]: http://eradman.com/entrproject/
73-
[black]: https://github.com/psf/black
74-
[isort]: https://pypi.org/project/isort/
75-
[flake8]: https://flake8.pycqa.org/
158+
[`entr(1)`]: http://eradman.com/entrproject/
159+
[ruff]: https://ruff.rs
160+
[mypy]: https://mypy-lang.org/

0 commit comments

Comments
 (0)