Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cf9f3ef

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 25e9482 commit cf9f3ef

File tree

6 files changed

+94
-292
lines changed

6 files changed

+94
-292
lines changed

‎.github/workflows/tests.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ jobs:
2929
cache: 'poetry'
3030

3131
- name: Install dependencies
32-
run: poetry install -E "docs test coverage lint format"
32+
run: poetry install -E "docs test coverage lint"
3333

34-
- name: Lint with flake8
35-
run: poetry run flake8
34+
- name: Lint with ruff
35+
run: poetry run ruff .
3636

3737
- name: Lint with mypy
3838
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

@@ -39,11 +33,11 @@ start_docs:
3933
design_docs:
4034
$(MAKE) -C docs design
4135

42-
flake8:
43-
poetry run flake8
36+
ruff:
37+
poetry run ruff .
4438

45-
watch_flake8:
46-
if command -v entr > /dev/null; then ${PY_FILES} | entr -c $(MAKE) flake8; else $(MAKE) flake8 entr_warn; fi
39+
watch_ruff:
40+
if command -v entr > /dev/null; then ${PY_FILES} | entr -c $(MAKE) ruff; else $(MAKE) ruff entr_warn; fi
4741

4842
mypy:
4943
poetry run mypy `${PY_FILES}`

‎docs/contributing/workflow.md‎

Lines changed: 56 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $ cd libvcs
1515
```
1616

1717
```console
18-
$ poetry install -E "docs test coverage lint format"
18+
$ poetry install -E "docs test coverage lint"
1919
```
2020

2121
Makefile commands prefixed with `watch_` will watch files and rerun.
@@ -49,69 +49,100 @@ Rebuild docs on file change: `make watch_docs` (requires [entr(1)])
4949
Rebuild docs and run server via one terminal: `make dev_docs` (requires above, and a `make(1)` with
5050
`-J` support, e.g. GNU Make)
5151

52-
## Formatting
52+
## Formatting / linting
5353

54-
The project uses [black] and [isort] (one after the other). Configurations are in `pyproject.toml`
55-
and `setup.cfg`:
54+
### ruff
5655

57-
- `make black isort`: Run `black` first, then `isort` to handle import nuances
58-
59-
## Linting
60-
61-
[flake8] and [mypy] run via CI in our GitHub Actions. See the configuration in `pyproject.toml` and
62-
`setup.cfg`.
63-
64-
### flake8
65-
66-
[flake8] provides fast, reliable, barebones styling and linting.
56+
The project uses [ruff] to handles formatting, sorting imports and linting.
6757

6858
````{tab} Command
6959
7060
poetry:
7161
7262
```console
73-
$ poetry run flake8
63+
$ poetry run ruff
7464
```
7565
7666
If you setup manually:
7767
7868
```console
79-
$ flake8
69+
$ ruff .
8070
```
8171
8272
````
8373

8474
````{tab} make
8575
8676
```console
87-
$ make flake8
77+
$ make ruff
8878
```
8979
9080
````
9181

9282
````{tab} Watch
9383
9484
```console
95-
$ make watch_flake8
85+
$ make watch_ruff
9686
```
9787
9888
requires [`entr(1)`].
9989
10090
````
10191

102-
````{tab} Configuration
92+
````{tab} Fix files
93+
94+
poetry:
95+
96+
```console
97+
$ poetry run ruff . --fix
98+
```
99+
100+
If you setup manually:
101+
102+
```console
103+
$ ruff . --fix
104+
```
105+
106+
````
107+
108+
### mypy
109+
110+
[mypy] is used for static type checking.
111+
112+
````{tab} Command
113+
114+
poetry:
115+
116+
```console
117+
$ poetry run mypy .
118+
```
119+
120+
If you setup manually:
121+
122+
```console
123+
$ mypy .
124+
```
125+
126+
````
127+
128+
````{tab} make
129+
130+
```console
131+
$ make mypy
132+
```
103133
104-
See `[flake8]` in setup.cfg.
134+
````
105135

106-
```{literalinclude} ../../setup.cfg
107-
:language: ini
108-
:start-at: "[flake8]"
109-
:end-before: "[isort]"
136+
````{tab} Watch
110137
138+
```console
139+
$ make watch_mypy
111140
```
112141
142+
requires [`entr(1)`].
113143
````
114144

145+
115146
### mypy
116147

117148
[mypy] is used for static type checking.
@@ -202,7 +233,5 @@ Update `__version__` in `__about__.py` and `pyproject.toml`::
202233
[poetry]: https://python-poetry.org/
203234
[entr(1)]: http://eradman.com/entrproject/
204235
[`entr(1)`]: http://eradman.com/entrproject/
205-
[black]: https://github.com/psf/black
206-
[isort]: https://pypi.org/project/isort/
207-
[flake8]: https://flake8.pycqa.org/
236+
[ruff]: https://ruff.rs
208237
[mypy]: http://mypy-lang.org/

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /