Skip to content

Commit

Permalink
ci!: Add ruff, replacing isort, black, flake8 and its plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
tony committed May 27, 2023
1 parent 641be77 commit d3613a0
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 351 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ jobs:
run: |
poetry install -E "test coverage lint"
- name: Lint with flake8
- name: Lint with ruff
run: |
poetry run flake8
poetry run ruff .
- name: Lint with mypy
run: poetry run mypy .
Expand Down
14 changes: 4 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ entr_warn:
@echo "See https://eradman.com/entrproject/ "
@echo "----------------------------------------------------------"

isort:
poetry run isort `${PY_FILES}`

black:
poetry run black `${PY_FILES}`

test:
poetry run py.test $(test)

Expand Down Expand Up @@ -44,11 +38,11 @@ serve_docs:
dev_docs:
$(MAKE) -j watch_docs serve_docs

flake8:
poetry run flake8
ruff:
poetry run ruff .

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

mypy:
poetry run mypy `${PY_FILES}`
Expand Down
38 changes: 19 additions & 19 deletions docs/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $ cd libtmux
```

```console
$ poetry install -E "docs test coverage lint format"
$ poetry install -E "docs test coverage lint ruff"
```

Makefile commands prefixed with `watch_` will watch files and rerun.
Expand Down Expand Up @@ -61,60 +61,62 @@ and `setup.cfg`:

## Linting

[flake8] and [mypy] run via CI in our GitHub Actions. See the configuration in `pyproject.toml` and
`setup.cfg`.
### ruff

### flake8

[flake8] provides fast, reliable, barebones styling and linting.
The project uses [ruff] to handles formatting, sorting imports and linting.

````{tab} Command
poetry:
```console
$ poetry run flake8
$ poetry run ruff
```
If you setup manually:
```console
$ flake8
$ ruff .
```
````

````{tab} make
```console
$ make flake8
$ make ruff
```
````

````{tab} Watch
```console
$ make watch_flake8
$ make watch_ruff
```
requires [`entr(1)`].
````

````{tab} Configuration
````{tab} Fix files
See `[flake8]` in setup.cfg.
poetry:
```{literalinclude} ../setup.cfg
:language: ini
:start-at: "[flake8]"
:end-before: "[isort]"
```console
$ poetry run ruff . --fix
```
If you setup manually:
```console
$ ruff . --fix
```
````



### mypy

[mypy] is used for static type checking.
Expand Down Expand Up @@ -213,7 +215,5 @@ Update `__version__` in `__about__.py` and `pyproject.toml`::
[poetry]: https://python-poetry.org/
[entr(1)]: http://eradman.com/entrproject/
[`entr(1)`]: http://eradman.com/entrproject/
[black]: https://github.com/psf/black
[isort]: https://pypi.org/project/isort/
[flake8]: https://flake8.pycqa.org/
[ruff]: https://ruff.rs
[mypy]: http://mypy-lang.org/
Loading

0 comments on commit d3613a0

Please sign in to comment.