py-check.mk: Run isort with "make format"
If /usr/bin/isort is found, run it during "make format" to get a defined way the imports are sorted. tool.isort in pyproject.toml is updated to match the other fixers. Commit the fallout of this change. Running the other fixers alone doesn't change the formatting, so this should be safe. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
a7dd607667
commit
5d77955ed9
56 changed files with 109 additions and 67 deletions
|
|
@ -29,6 +29,10 @@ ifndef PY_CHECK_RUFF
|
|||
endif
|
||||
endif
|
||||
|
||||
ifndef PY_CHECK_ISORT
|
||||
PY_CHECK_ISORT := $(firstword $(wildcard /usr/bin/isort))
|
||||
endif
|
||||
|
||||
ifndef PY_CHECK_YAPF
|
||||
PY_CHECK_YAPF := $(firstword $(wildcard /usr/bin/yapf /usr/bin/yapf3))
|
||||
endif
|
||||
|
|
@ -67,6 +71,9 @@ endif
|
|||
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/^ //}}'
|
||||
ifneq ($(PY_CHECK_ISORT),)
|
||||
$(PY_CHECK_ISORT) $(PY_CHECK_ROOTS)
|
||||
endif
|
||||
ifneq ($(PY_CHECK_YAPF),)
|
||||
$(PY_CHECK_YAPF) --in-place --recursive $(PY_CHECK_ROOTS)
|
||||
endif
|
||||
|
|
|
|||
Loading…
Reference in a new issue