|
1 | 1 | #* Variables |
2 | | -SHELL := /usr/bin/env bash |
| 2 | +SHELL := /usr/bin/env bash -o pipefail |
3 | 3 | PYTHON := python3 |
4 | | -PYTHONPATH := `pwd` |
5 | 4 |
|
6 | | -#* Poetry |
7 | | -.PHONY: poetry-download |
8 | | -poetry-download: |
9 | | - curl -sSL https://install.python-poetry.org | POETRY_VERSION=1.8.5 $(PYTHON) - |
| 5 | +#* Directories with source code |
| 6 | +CODE = hooks tests |
| 7 | +TESTS = tests |
10 | 8 |
|
11 | | -.PHONY: poetry-remove |
12 | | -poetry-remove: |
13 | | - curl -sSL https://install.python-poetry.org | $(PYTHON) - --uninstall |
| 9 | +#* uv package manager |
| 10 | +.PHONY: uv-install |
| 11 | +uv-install: |
| 12 | + curl -LsSf https://astral.sh/uv/install.sh | sh |
14 | 13 |
|
15 | 14 | #* Installation |
16 | 15 | .PHONY: install |
17 | 16 | install: |
18 | | - poetry lock -n && poetry export --without-hashes > requirements.txt |
19 | | - poetry install -n |
20 | | - poetry run mypy --install-types --non-interactive hooks tests |
| 17 | + uv sync |
21 | 18 |
|
22 | 19 | .PHONY: pre-commit-install |
23 | 20 | pre-commit-install: |
24 | | - poetry run pre-commit install |
| 21 | + uv run pre-commit install |
25 | 22 |
|
26 | 23 | #* Formatters |
27 | 24 | .PHONY: codestyle |
28 | 25 | codestyle: |
29 | | - poetry run pyupgrade --exit-zero-even-if-changed --py37-plus **/*.py |
30 | | - poetry run isort --settings-path pyproject.toml hooks tests |
31 | | - poetry run black --config pyproject.toml hooks tests |
| 26 | + uv run ruff format $(CODE) |
| 27 | + uv run ruff check $(CODE) --fix-only |
32 | 28 |
|
33 | | -.PHONY: formatting |
34 | | -formatting: codestyle |
| 29 | +.PHONY: format |
| 30 | +format: codestyle |
35 | 31 |
|
36 | | -#* Linting |
| 32 | +#* Test |
37 | 33 | .PHONY: test |
38 | 34 | test: |
39 | | - PYTHONPATH=$(PYTHONPATH) poetry run pytest -c pyproject.toml --cov-report=html --cov=hooks tests/ |
| 35 | + uv run pytest |
| 36 | + uv run coverage xml |
| 37 | + |
| 38 | +# Validate dependencies |
| 39 | +.PHONY: check-uv |
| 40 | +check-uv: |
| 41 | + uv lock --check |
| 42 | + |
| 43 | +.PHONY: check-deptry |
| 44 | +check-deptry: |
| 45 | + uv run deptry . |
| 46 | + |
| 47 | +.PHONY: check-dependencies |
| 48 | +check-dependencies: check-uv check-deptry |
| 49 | + |
| 50 | +#* Static linters |
| 51 | + |
| 52 | +.PHONY: check-ruff |
| 53 | +check-ruff: |
| 54 | + uv run ruff check $(CODE) --no-fix |
40 | 55 |
|
41 | 56 | .PHONY: check-codestyle |
42 | 57 | check-codestyle: |
43 | | - poetry run isort --diff --check-only --settings-path pyproject.toml hooks tests |
44 | | - poetry run black --diff --check --config pyproject.toml hooks tests |
45 | | - poetry run darglint --verbosity 2 hooks tests |
| 58 | + uv run ruff format $(CODE) --check |
| 59 | + |
| 60 | + |
| 61 | +.PHONY: check-ruff-github |
| 62 | +check-ruff-github: |
| 63 | + uv run ruff check $(CODE) --no-fix --output-format=github |
46 | 64 |
|
47 | | -.PHONY: mypy |
48 | | -mypy: |
49 | | - poetry run mypy --config-file pyproject.toml hooks tests |
| 65 | + |
| 66 | +.PHONY: check-mypy |
| 67 | +check-mypy: |
| 68 | + uv run mypy --install-types --non-interactive --config-file pyproject.toml $(CODE) |
| 69 | + |
| 70 | +.PHONY: static-lint |
| 71 | +static-lint: check-ruff check-mypy |
| 72 | + |
| 73 | +#* Check safety |
50 | 74 |
|
51 | 75 | .PHONY: check-safety |
52 | 76 | check-safety: |
53 | | - poetry check |
54 | | - poetry run safety check --full-report |
55 | | - poetry run bandit -ll --recursive hooks |
| 77 | + uv run safety check --full-report |
56 | 78 |
|
57 | 79 | .PHONY: lint |
58 | | -lint: test check-codestyle mypy check-safety |
| 80 | +lint: check-dependencies check-codestyle static-lint |
59 | 81 |
|
60 | | -.PHONY: update-dev-deps |
61 | | -update-dev-deps: |
62 | | - poetry add -D black@latest bandit@latest darglint@latest "isort[colors]@latest" mypy@latest pre-commit@latest pydocstyle@latest pylint@latest pytest@latest pyupgrade@latest safety@latest coverage@latest pytest-html@latest pytest-cov@latest |
| 82 | +# Currently not supported in uv: https://github.com/astral-sh/uv/issues/6794 |
| 83 | +#.PHONY: update-dev-deps |
| 84 | +#update-dev-deps: |
| 85 | +# poetry add -G dev mypy@latest pre-commit@latest pytest@latest deptry@latest \ |
| 86 | +# coverage@latest safety@latest typeguard@latest ruff@latest |
| 87 | + |
| 88 | +.PHONY: update |
| 89 | +update: |
| 90 | + uv lock --upgrade |
63 | 91 |
|
64 | 92 | #* Cleaning |
65 | 93 | .PHONY: pycache-remove |
66 | 94 | pycache-remove: |
67 | | - find . | grep -E "(__pycache__|\.pyc|\.pyo$$)" | xargs rm -rf |
| 95 | + find . | grep -E "(__pycache__|\.pyc|\.pyo$$)" | xargs rm -rf || true |
68 | 96 |
|
69 | 97 | .PHONY: dsstore-remove |
70 | 98 | dsstore-remove: |
71 | | - find . | grep -E ".DS_Store" | xargs rm -rf |
| 99 | + find . | grep -E ".DS_Store" | xargs rm -rf || true |
72 | 100 |
|
73 | 101 | .PHONY: mypycache-remove |
74 | 102 | mypycache-remove: |
75 | | - find . | grep -E ".mypy_cache" | xargs rm -rf |
| 103 | + find . | grep -E ".mypy_cache" | xargs rm -rf || true |
76 | 104 |
|
77 | 105 | .PHONY: ipynbcheckpoints-remove |
78 | 106 | ipynbcheckpoints-remove: |
79 | | - find . | grep -E ".ipynb_checkpoints" | xargs rm -rf |
| 107 | + find . | grep -E ".ipynb_checkpoints" | xargs rm -rf || true |
80 | 108 |
|
81 | 109 | .PHONY: pytestcache-remove |
82 | 110 | pytestcache-remove: |
83 | | - find . | grep -E ".pytest_cache" | xargs rm -rf |
| 111 | + find . | grep -E ".pytest_cache" | xargs rm -rf || true |
| 112 | + |
| 113 | +.PHONY: ruffcache-remove |
| 114 | +ruffcache-remove: |
| 115 | + find . | grep -E ".ruff_cache" | xargs rm -rf || true |
84 | 116 |
|
85 | 117 | .PHONY: build-remove |
86 | 118 | build-remove: |
87 | 119 | rm -rf build/ |
88 | 120 |
|
| 121 | +.PHONY: reports-remove |
| 122 | +reports-remove: |
| 123 | + rm -rf reports/ |
| 124 | + |
89 | 125 | .PHONY: cleanup |
90 | | -cleanup: pycache-remove dsstore-remove mypycache-remove ipynbcheckpoints-remove pytestcache-remove |
| 126 | +cleanup: pycache-remove dsstore-remove mypycache-remove ruffcache-remove \ |
| 127 | +ipynbcheckpoints-remove pytestcache-remove reports-remove |
0 commit comments