-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
138 lines (115 loc) · 3.25 KB
/
Makefile
File metadata and controls
138 lines (115 loc) · 3.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
SOURCE_FILES = *.py
NON_TEXT_FILES_REGEX = "\.pyc$$|\.git/|\.idea/|^\.venv/|^test_data/|^\.coverage$$|^\.mypy_cache/|^.pytest_cache/|^.ruff_cache/"
.PHONY: \
whitespace-format-check \
whitespace-format \
ruff-format-check \
ruff-format \
pydocstyle \
ruff \
ruff-fix \
flake8 \
pylint \
mypy \
lint \
test \
coverage \
clean \
install-python \
create-environment \
delete-environment \
install-dependencies \
build-package \
publish-to-pypi \
publish-to-test-pypi \
check-lock-file \
whitespace-format-check:
# Check whitespace formatting.
whitespace-format \
--check-only \
--color \
--verbose \
--new-line-marker linux \
--normalize-new-line-markers \
--add-new-line-marker-at-end-of-file \
--remove-trailing-whitespace \
--remove-trailing-empty-lines \
--normalize-non-standard-whitespace replace \
--normalize-whitespace-only-files empty \
--exclude $(NON_TEXT_FILES_REGEX) .
whitespace-format:
# Reformat code.
whitespace-format \
--color \
--verbose \
--new-line-marker linux \
--normalize-new-line-markers \
--add-new-line-marker-at-end-of-file \
--remove-trailing-whitespace \
--remove-trailing-empty-lines \
--normalize-non-standard-whitespace replace \
--normalize-whitespace-only-files empty \
--exclude $(NON_TEXT_FILES_REGEX) .
ruff-format-check:
# Check code formatting.
ruff format --check --diff $(SOURCE_FILES)
ruff-format:
# Reformat code.
ruff format $(SOURCE_FILES)
pydocstyle:
# Check docstrings
pydocstyle --verbose --explain --source --count $(SOURCE_FILES)
ruff:
# Check code style with ruff.
ruff check ./
ruff-fix:
# Fix code style with ruff
ruff check --fix ./
flake8:
# Check PEP8 code style.
flake8 --color=always --exclude="*_pb2.py,*_rpc.py,*_twirp.py" $(SOURCE_FILES)
pylint:
# Static code analysis.
pylint --output-format=colorized --ignore-patterns="_pb2.py,_rpc.py,_twirp.py" --rcfile=pylintrc $(SOURCE_FILES)
mypy:
# Check type hints.
mypy --exclude ".*_pb2.py$$|.*_rpc.py$$|.*_twirp.py$$" $(SOURCE_FILES)
lint: check-lock-file whitespace-format-check ruff-format-check pydocstyle ruff flake8 pylint mypy
test:
# Run unit tests.
pytest --verbose ./
coverage:
# Compute unit test code coverage.
coverage run -m pytest --verbose --junit-xml=pytest_results/pytest.xml ./
coverage report --show-missing
coverage xml
clean:
# Remove temporary files.
rm -rf logs/*.log pytest_results/ .coverage *.egg-info/ dist/ .mypy_cache/ .pytest_cache/ .ruff_cache/
find . -name "__pycache__" -prune -exec rm -rf {} \;
find . -name ".pytest_cache" -prune -exec rm -rf {} \;
find . -name ".mypy_cache" -prune -exec rm -rf {} \;
install-python:
# Install the correct version of python.
uv python install --managed-python
create-environment:
# Create virtual environment.
uv venv --clear --managed-python
delete-environment:
# Delete virtual environment.
rm -rf .venv/
install-dependencies:
# Install all dependencies.
uv sync --locked --all-extras --dev
build-package:
# Build a wheel package.
uv build --clear
publish-to-pypi:
# Publish package to PyPI.
uv publish --index pypi
publish-to-test-pypi:
# Publish package to Test-PyPI.
uv publish --index test-pypi
check-lock-file:
# Check if uv.lock is consistent with pyproject.toml file.
uv lock --check