- Use ruff and yapf for the targets py-check-syntax, py-format and py-check-format.- Add a pyproject.toml for those. It also includes configuration for isort, albeit not being directly used in the linter targets.- Make .gitignore igore that in newly created projects.
- Add ruff, yapf and isort to pkg.requires.release, anticipating their use by CI.Signed-off-by: Jan Lindemann <jan@janware.com>
34 lines
990 B
Makefile
34 lines
990 B
Makefile
TD_COPY_FILES += pyproject.toml
|
|
|
|
PY_CHECK_EXCLUDE ?=
|
|
PY_SRC_ROOT += $(wildcard $(TOPDIR)/src $(TOPDIR)/tools)
|
|
|
|
all:
|
|
|
|
format: py-format
|
|
check-syntax: py-check-syntax
|
|
check-format: py-check-format
|
|
|
|
py-check: py-check-syntax py-check-format
|
|
py-check-syntax:
|
|
ruff check $(addprefix --exclude ,$(PY_CHECK_EXCLUDE)) $(PY_SRC_ROOT)
|
|
mypy $(addprefix --exclude ,$(PY_CHECK_EXCLUDE)) $(PY_SRC_ROOT)
|
|
|
|
py-check-format:
|
|
yapf --diff --recursive .
|
|
|
|
py-format:
|
|
find . -type f -name '*.py' -print0 | \
|
|
xargs -0 sed -i -E '1{/^# -\*- coding: utf-8 -\*-$$/{:a;N;/\n[[:space:]]*$$/ba;s/^# -\*- coding: utf-8 -\*-\n([[:space:]]*\n)*/ /;s/^ //}}'
|
|
yapf --in-place --recursive .
|
|
|
|
py-format-assignments:
|
|
find . \
|
|
-path './.git' -prune -o \
|
|
-type f -name '*.py' \
|
|
-execdir /usr/bin/sed -i 's/^\(\s\+[a-zA-Z0-9_]\+\)=\([^,[:space:]]\+\)\([,(]\)*\s*$$/\1 = \2\3/g' {} '+'
|
|
git diff --exit-code
|
|
|
|
clean.topdir: clean.py-check
|
|
clean.py-check:
|
|
rm -rf .mypy_cache
|