-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
96 lines (77 loc) · 2.91 KB
/
Makefile
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
.PHONY: whitespace-format-check whitespace-format black-check pydocstyle black-format pylint flake8 isort-check isort-format mypy test coverage clean install-python create-environment delete-environment install-dependencies build-package
PYTHON_ENVIRONMENT = "bibliography"
PYTHON_VERSION = "3.8.5"
SOURCE_FILES = *.py
whitespace-format-check:
# Check whitespace formatting.
whitespace-format --check-only --color --new-line-marker linux \
--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 ".pyc$$" *
whitespace-format:
# Reformat code.
whitespace-format --color --new-line-marker linux \
--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 ".pyc$$" *
black-check:
# Check code formatting.
black --diff --check --color --exclude "_pb2.py|_rpc.py|_twirp.py" $(SOURCE_FILES)
black-format:
# Reformat code.
black --exclude "_pb2.py|_rpc.py|_twirp.py" $(SOURCE_FILES)
pydocstyle:
# Check docstrings
python -m pydocstyle --verbose --explain --source --count $(SOURCE_FILES)
pylint:
# Static code analysis.
pylint --output-format=colorized --ignore-patterns="_pb2.py,_rpc.py,_twirp.py" --rcfile=pylintrc $(SOURCE_FILES)
flake8:
# Check PEP8 code style.
flake8 --color=always --exclude="*_pb2.py,*_rpc.py,*_twirp.py" $(SOURCE_FILES)
isort-check:
# Check imports.
isort --check-only --diff --color --skip-glob="*_pb2.py" --skip-glob="*_rpc.py" --skip-glob="*_twirp.py" $(SOURCE_FILES)
isort-format:
# Format imports.
isort --color --skip-glob="*_pb2.py" --skip-glob="*_rpc.py" --skip-glob="*_twirp.py" $(SOURCE_FILES)
mypy:
# Check type hints.
mypy --config-file "mypy.ini" --exclude ".*_pb2.py$$|.*_rpc.py$$|.*_twirp.py$$" $(SOURCE_FILES)
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/
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.
pyenv install $(PYTHON_VERSION)
create-environment:
# Create virtual environment.
pyenv virtualenv $(PYTHON_VERSION) $(PYTHON_ENVIRONMENT)
pyenv local $(PYTHON_ENVIRONMENT)
pip install --upgrade pip
delete-environment:
# Delete virtual environment.
pyenv virtualenv-delete $(PYTHON_ENVIRONMENT)
install-dependencies:
# Install all dependencies.
poetry install --verbose
build-package:
# Build a wheel package.
poetry build