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 e07c876 commit 397b4ec
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 333 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@ jobs:

- name: Install dependencies
run: |
poetry install -E "docs test coverage lint format"
poetry install -E "docs test coverage lint"
poetry run pip install docutils~=${{ matrix.docutils-version }}
- name: Print python versions
run: |
python -V
poetry run python -V
- name: Lint with flake8
run: poetry run flake8
- name: Lint with ruff
run: 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 @@ -12,12 +12,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 All @@ -36,11 +30,11 @@ start_docs:
design_docs:
$(MAKE) -C docs design

flake8:
flake8
ruff:
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
99 changes: 92 additions & 7 deletions docs/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,96 @@ Rebuild docs and run server via one terminal: `make dev_docs` (requires above, a

## Formatting / Linting

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

`make black isort`: Run `black` first, then `isort` to handle import nuances
`make flake8`, to watch (requires `entr(1)`): `make watch_flake8`
The project uses [ruff] to handles formatting, sorting imports and linting.

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

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

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

````{tab} Fix files
poetry:
```console
$ poetry run ruff . --fix
```
If you setup manually:
```console
$ ruff . --fix
```
````

### mypy

[mypy] is used for static type checking.

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

````{tab} make
```console
$ make mypy
```
````

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

## Releasing

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

[poetry]: https://python-poetry.org/
[entr(1)]: http://eradman.com/entrproject/
[black]: https://github.com/psf/black
[isort]: https://pypi.org/project/isort/
[flake8]: https://flake8.pycqa.org/
[`entr(1)`]: http://eradman.com/entrproject/
[ruff]: https://ruff.rs
[mypy]: https://mypy-lang.org/
Loading

0 comments on commit 397b4ec

Please sign in to comment.