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 apt-get install -y git make python3 python3-poetry --no-install-recommends
poetry install --only lint,test poetry install --only lint,test
- name: Run linters to enforce code style - 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 - name: Check that the QA script is up to date with the docs
run: "./dev_scripts/qa.py --check-refs" 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) GIT_DESC=$$(git describe)
JUNIT_FLAGS := --capture=sys -o junit_logging=all JUNIT_FLAGS := --capture=sys -o junit_logging=all
.PHONY: lint-black lint-ruff: ## check the python source code with various linter rules through ruff
lint-black: ## check python source code formatting issues, with black ruff check
black --check --diff ./
.PHONY: lint-black-apply lint-ruff-apply: ## apply all fixes made by ruff to the source code
lint-black-apply: ## apply black's source code formatting suggestions ruff check --fix
black ./
.PHONY: lint-isort format-ruff: ## Check the formatting of the python source code with ruff
lint-isort: ## check imports are organized, with isort ruff format --check
isort --check --diff ./
.PHONY: lint-isort-apply format-ruff-apply: ## apply all the formatting suggestions from ruff
lint-isort-apply: ## apply isort's imports organization suggestions ruff format
isort ./
MYPY_ARGS := --ignore-missing-imports \ MYPY_ARGS := --ignore-missing-imports \
--disallow-incomplete-defs \ --disallow-incomplete-defs \
@ -34,11 +30,11 @@ mypy-tests:
mypy: mypy-host mypy-tests ## check type hints with mypy mypy: mypy-host mypy-tests ## check type hints with mypy
.PHONY: lint .PHONY: check
lint: lint-black lint-isort mypy ## check the code with various linters check: lint-ruff format-ruff mypy ## check the code with ruff and mypy
.PHONY: lint-apply .PHONY: fix
format: lint-black-apply lint-isort-apply ## apply all the linter's suggestions fix: lint-ruff-apply format-ruff-apply ## apply all the suggestions from ruff
.PHONY: test .PHONY: test
test: test: