2222
2323MODULE =cwl-upgrader
2424PACKAGE =cwlupgrader
25+ EXTRAS =
2526
2627# `SHELL=bash` doesn't work for some, so don't use BASH-isms like
2728# `[[` conditional expressions.
2829PYSOURCES =$(wildcard cwlupgrader/** .py tests/* .py) setup.py
29- DEVPKGS =diff_cover black pylint coverage pep257 pytest-xdist \
30- flake8 flake8-bugbear pyupgrade mypy
30+ DEVPKGS =diff_cover black pylint pep257 pydocstyle flake8 tox tox-pyenv \
31+ isort wheel autoflake flake8-bugbear pyupgrade bandit \
32+ -rtest-requirements.txt -rmypy-requirements.txt
3133DEBDEVPKGS =pylint python3-coverage sloccount \
3234 python3-flake8 shellcheck
33- VERSION =1.2.1 # please also update setup.py
35+ VERSION =1.2.2 # please also update setup.py
3436
3537# # all : default task
36- all :
37- pip install -e .
38+ all : dev
3839
3940# # help : print this help message and exit
4041help : Makefile
4142 @sed -n ' s/^##//p' $<
4243
4344# # install-dep : install most of the development dependencies via pip
44- install-dep :
45- pip install --upgrade $(DEVPKGS )
45+ install-dep : install-dependencies
4646
47- # # install-deb-dep: install most of the dev dependencies via apt-get
48- install-deb-dep :
49- sudo apt-get install $( DEBDEVPKGS )
47+ install-dependencies : FORCE
48+ pip install --upgrade $( DEVPKGS )
49+ pip install -r requirements.txt -r mypy-requirements.txt
5050
51- # # install : install the ${MODULE} module and scripts
51+ # # install : install the ${MODULE} module and script(s)
5252install : FORCE
53- pip install .
53+ pip install .$(EXTRAS )
54+
55+ # # dev : install the ${MODULE} module in dev mode
56+ dev : install-dep
57+ pip install -e .$(EXTRAS )
5458
5559# # dist : create a module package for distribution
5660dist : dist/${MODULE}-$(VERSION ) .tar.gz
@@ -67,8 +71,11 @@ clean: FORCE
6771
6872# Linting and code style related targets
6973# # sorting imports using isort: https://github.com/timothycrosley/isort
70- sort_imports :
71- isort ${PACKAGE} /* .py tests/* .py setup.py
74+ sort_imports : $(PYSOURCES )
75+ isort $^ typeshed
76+
77+ remove_unused_imports : $(PYSOURCES )
78+ autoflake --in-place --remove-all-unused-imports $^
7279
7380pep257 : pydocstyle
7481# # pydocstyle : check Python code style
@@ -83,14 +90,17 @@ diff_pydocstyle_report: pydocstyle_report.txt
8390
8491# # format : check/fix all code indentation and formatting (runs black)
8592format :
86- black setup.py cwlupgrader
93+ black setup.py cwlupgrader tests
94+
95+ format-check :
96+ black --diff --check cwlupgrader setup.py typeshed
8797
8898# # pylint : run static code analysis on Python code
8999pylint : $(PYSOURCES )
90100 pylint --msg-template=" {path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
91101 $^ -j0|| true
92102
93- pylint_report.txt : ${ PYSOURCES}
103+ pylint_report.txt : $( PYSOURCES )
94104 pylint --msg-template=" {path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
95105 $^ -j0> $@ || true
96106
@@ -121,47 +131,51 @@ diff-cover.html: coverage.xml
121131 diff-cover --compare-branch main $^ --html-report $@
122132
123133# # test : run the ${MODULE} test suite
124- test : FORCE
134+ test : $( PYSOURCES )
125135 python setup.py test
126136
127137# # testcov : run the ${MODULE} test suite and collect coverage
128- testcov : $(pysources )
129- python setup.py test --addopts " --cov ${PACKAGE} "
138+ testcov : $(PYSOURCES )
139+ python setup.py test --addopts " --cov" ${PYTEST_EXTRA}
130140
131- sloccount.sc : ${ PYSOURCES} Makefile
141+ sloccount.sc : $( PYSOURCES ) Makefile
132142 sloccount --duplicates --wide --details $^ > $@
133143
134144# # sloccount : count lines of code
135- sloccount : ${ PYSOURCES} Makefile
145+ sloccount : $( PYSOURCES ) Makefile
136146 sloccount $^
137147
138148list-author-emails :
139149 @echo ' name, E-Mail Address'
140150 @git log --format=' %aN,%aE' | sort -u | grep -v ' root'
141151
142152mypy3 : mypy
143- mypy : ${ PYSOURCES}
153+ mypy : $( PYSOURCES )
144154 if ! test -f $( shell python3 -c ' import ruamel.yaml; import os.path; print(os.path.dirname(ruamel.yaml.__file__))' ) /py.typed ; \
145155 then \
146- rm -Rf typeshed/2and3/ ruamel/yaml ; \
156+ rm -Rf typeshed/ruamel/yaml ; \
147157 ln -s $(shell python3 -c 'import ruamel.yaml; import os.path; print(os.path.dirname(ruamel.yaml.__file__) )' ) \
148- typeshed/2and3/ ruamel/ ; \
158+ typeshed/ruamel/ ; \
149159 fi # if minimally required ruamel.yaml version is 0.15.99 or greater, than the above can be removed
150- MYPYPATH=$$ MYPYPATH:typeshed/3:typeshed/2and3 mypy --disallow-untyped-calls \
151- --warn-redundant-casts \
152- ${PACKAGE}
160+ MYPYPATH=$$ MYPYPATH:typeshed mypy $^
153161
154- pyupgrade : $(filter-out schema_salad/metaschema.py,${ PYSOURCES} )
162+ pyupgrade : $(PYSOURCES )
155163 pyupgrade --exit-zero-even-if-changed --py36-plus $^
156164
157- release : FORCE
165+ release-test : FORCE
166+ git diff-index --quiet HEAD -- || ( echo You have uncommited changes, please commit them and try again; false )
158167 ./release-test.sh
168+
169+ release : release-test
159170 . testenv2/bin/activate && \
160171 python testenv2/src/${MODULE} /setup.py sdist bdist_wheel && \
161172 pip install twine && \
162173 twine upload testenv2/src/${MODULE} /dist/* && \
163174 git tag v${VERSION} && git push --tags
164175
176+ flake8 : $(PYSOURCES )
177+ flake8 $^
178+
165179FORCE :
166180
167181# Use this to print the value of a Makefile variable
0 commit comments