|
1 | 1 | # Directories |
2 | | -SRC_DIRS := src/ test/ # FIXME |
| 2 | +SRC_DIRS := project_name/ test/ # FIXME |
3 | 3 |
|
4 | 4 | # Tasks |
5 | 5 | .PHONY: help |
6 | 6 | help: |
7 | 7 | @echo "Available targets:" |
8 | | - @echo " format : Format code using Black and isort" |
9 | | - @echo " check_format : Check code formatting with Black and isort" |
10 | | - @echo " lint : Run pylint and Mypy for static code analysis" |
| 8 | + @echo " format : Format code using Ruff format" |
| 9 | + @echo " check_format : Check code formatting with Ruff format" |
| 10 | + @echo " lint : Run Ruff linter and Mypy for static code analysis" |
11 | 11 | @echo " test : Run tests using pytest" |
12 | 12 | @echo " clean : Clean up caches and build artifacts" |
13 | 13 | @echo " run_local_checks : Run format, lint, and test" |
14 | 14 | @echo " help : Show this help message" |
15 | 15 |
|
16 | 16 | .PHONY: format |
17 | 17 | format: |
18 | | - @echo "==> Formatting code..." |
19 | | - @poetry run black $(SRC_DIRS) |
20 | 18 | @echo "==> Sorting imports..." |
21 | | - @poetry run isort $(SRC_DIRS) |
| 19 | + @# Currently, the Ruff formatter does not sort imports, see https://docs.astral.sh/ruff/formatter/#sorting-imports |
| 20 | + @poetry run ruff check --select I --fix $(SRC_DIRS) |
| 21 | + @echo "=====> Formatting code..." |
| 22 | + @poetry run ruff format $(SRC_DIRS) |
22 | 23 |
|
23 | 24 | .PHONY: check_format |
24 | 25 | check_format: |
25 | | - @echo "==> Checking format..." |
26 | | - @poetry run black --check --diff $(SRC_DIRS) |
27 | | - @echo "==> Checking isort..." |
28 | | - @poetry run isort --check --diff $(SRC_DIRS) |
| 26 | + @echo "=====> Checking format..." |
| 27 | + @poetry run ruff format --check --diff $(SRC_DIRS) |
| 28 | + @echo "=====> Checking imports are sorted..." |
| 29 | + @poetry run ruff check --select I --exit-non-zero-on-fix $(SRC_DIRS) |
| 30 | + |
29 | 31 |
|
30 | 32 | .PHONY: lint |
31 | 33 | lint: |
32 | | - @echo "==> Running pylint..." |
33 | | - @poetry run pylint $(SRC_DIRS) |
34 | | - @echo "==> Running Mypy..." |
| 34 | + @echo "=====> Running Ruff linter..." |
| 35 | + @poetry run ruff check $(SRC_DIRS) |
| 36 | + @echo "=====> Running Mypy..." |
35 | 37 | @poetry run mypy $(SRC_DIRS) |
36 | 38 |
|
37 | 39 | .PHONY: test |
38 | 40 | test: |
39 | | - @echo "==> Running tests..." |
| 41 | + @echo "=====> Running tests..." |
40 | 42 | @poetry run pytest |
41 | 43 |
|
42 | 44 | .PHONY: clean |
43 | 45 | clean: |
44 | | - @echo "==> Cleaning caches..." |
45 | | - @find ./ -name '*.pyc' -exec rm -f {} \; |
46 | | - @find ./ -name '__pycache__' -exec rm -rf {} \; |
47 | | - @rm -rf .cache |
48 | | - @rm -rf .pytest_cache |
49 | | - @rm -rf .mypy_cache |
50 | | - @rm -rf build |
51 | | - @rm -rf dist |
52 | | - @rm -rf *.egg-info |
| 46 | + @echo "=====> Cleaning caches..." |
| 47 | + @poetry run ruff clean |
| 48 | + @rm -rf .cache .pytest_cache .mypy_cache build dist *.egg-info |
53 | 49 |
|
54 | 50 | run_local_checks: format lint test |
0 commit comments