Lint: adapt Makefile targets for ruff

- Add new targets for checking and applying `ruff check` and `ruff format`.

- Add targets `fix` and `check` for convenience.

- Also use the new `check` target in CI.
This commit is contained in:
jkarasti 2024-11-25 18:48:22 +02:00
parent 8cf2246855
commit 6cd736de69
2 changed files with 13 additions and 17 deletions

View file

@ -38,7 +38,7 @@ jobs:
apt-get install -y git make python3 python3-poetry --no-install-recommends
poetry install --only lint,test
- name: Run linters to enforce code style
run: poetry run make lint
run: poetry run make check
- name: Check that the QA script is up to date with the docs
run: "./dev_scripts/qa.py --check-refs"

View file

@ -2,21 +2,17 @@ LARGE_TEST_REPO_DIR:=tests/test_docs_large
GIT_DESC=$$(git describe)
JUNIT_FLAGS := --capture=sys -o junit_logging=all
.PHONY: lint-black
lint-black: ## check python source code formatting issues, with black
black --check --diff ./
lint-ruff: ## check the python source code with various linter rules through ruff
ruff check
.PHONY: lint-black-apply
lint-black-apply: ## apply black's source code formatting suggestions
black ./
lint-ruff-apply: ## apply all fixes made by ruff to the source code
ruff check --fix
.PHONY: lint-isort
lint-isort: ## check imports are organized, with isort
isort --check --diff ./
format-ruff: ## Check the formatting of the python source code with ruff
ruff format --check
.PHONY: lint-isort-apply
lint-isort-apply: ## apply isort's imports organization suggestions
isort ./
format-ruff-apply: ## apply all the formatting suggestions from ruff
ruff format
MYPY_ARGS := --ignore-missing-imports \
--disallow-incomplete-defs \
@ -34,11 +30,11 @@ mypy-tests:
mypy: mypy-host mypy-tests ## check type hints with mypy
.PHONY: lint
lint: lint-black lint-isort mypy ## check the code with various linters
.PHONY: check
check: lint-ruff format-ruff mypy ## check the code with ruff and mypy
.PHONY: lint-apply
format: lint-black-apply lint-isort-apply ## apply all the linter's suggestions
.PHONY: fix
fix: lint-ruff-apply format-ruff-apply ## apply all the suggestions from ruff
.PHONY: test
test: