forked from jamescooke/flake8-aaa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
120 lines (100 loc) · 3.21 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
lint_files=setup.py src/flake8_aaa tests
rst_files=README.rst CHANGELOG.rst
# Lists of examples to pass through command line checks
# NOQA examples in /examples/good will fail because CMD does not respect noqa
# comments in the same way that flake8 does.
good_examples = $(wildcard examples/good/*.py examples/good/black/*.py) examples/good/noqa/test_cmd.py
bad_examples = $(wildcard examples/good/noqa/test_0*.py examples/good/black/noqa/test_0*.py examples/bad/*.py)
# --- Tox recipes ---
.PHONY: lint
lint:
@echo "=== flake8 ==="
flake8 $(lint_files)
@echo "=== mypy ==="
MYPYPATH=stubs mypy src/flake8_aaa tests
@echo "=== isort ==="
isort --check --diff $(lint_files)
@echo "=== yapf ==="
yapf --recursive --diff $(lint_files)
@echo "=== rst ==="
restructuredtext-lint $(rst_files)
@echo "=== setup.py ==="
python setup.py check --metadata --strict
.PHONY: lintexamples
lintexamples:
@echo "=== flake8 ==="
flake8 examples/good examples/bad | sort > flake8.out
diff examples/bad/flake8_expected.out flake8.out
@echo "=== mypy ==="
mypy examples/conftest.py examples/good --ignore-missing-imports --exclude examples/black/ --no-incremental
mypy examples/bad --ignore-missing-imports
@echo "=== black ==="
black --check --diff --verbose examples/black
.PHONY: lintexamplespy38
lintexamplespy38:
@echo "=== flake8 ==="
flake8 examples/good_py38
@echo "=== mypy ==="
mypy examples/good_py38
.PHONY: docs
docs:
tox run -e py310-docs
.PHONY: cmd
cmd:
for i in $(good_examples); do \
echo "\n=== $$i ==="; \
python -m flake8_aaa "$$i" || break -1; \
done
# NOTE: Checks that all bad example files give at least 1 error and all return
# an error code greater than 0. The `echo;` is used to wipe the error code from
# the last test, or the for loop fails.
.PHONY: cmdbad
cmdbad:
for i in $(bad_examples); do \
echo "\n=== $$i ==="; \
python -m flake8_aaa "$$i" && break -1; \
echo; \
done
# --- Local dev: Building / Publishing ---
# Generate version signature used in README.rst
.PHONY: signature
signature:
tox exec -e py311-meta_plugin_dogfood -- flake8 --version
.PHONY: clean
clean:
rm -rf dist build .tox .pytest_cache src/flake8_aaa.egg-info docs/_build/
find . -name '*.pyc' -delete
find src/ examples/ tests/ -name __pycache__ -type d -delete
.PHONY: sdist
sdist:
python setup.py sdist
.PHONY: bdist_wheel
bdist_wheel:
pip install wheel
python setup.py bdist_wheel
.PHONY: testpypi
testpypi: clean sdist bdist_wheel
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
.PHONY: pypi
pypi: sdist bdist_wheel
twine upload --repository-url https://upload.pypi.org/legacy/ dist/*
.PHONY: on_master
on_master:
./on_master.sh
.PHONY: tag
tag: on_master
git tag -a $$(python -c 'from src.flake8_aaa.__about__ import __version__; print("v{}".format(__version__))')
.PHONY: fixlint
fixlint:
@echo "=== fixing isort ==="
isort --quiet --recursive $(lint_files)
@echo "=== fixing yapf ==="
yapf --recursive --in-place $(lint_files)
.PHONY: fixlintexamples
fixlintexamples:
@echo "=== Fixing black using tox env ==="
tox e -e py37-lint_examples -- black examples/black
# Trigger a new copy of Black-formatted examples to be generated
.PHONY: black_examples
black_examples:
$(MAKE) -C examples clean all