py-topdir.mk: py-format|check-annotation-imports

Add two new targets, basically

py-check-annotation-imports: ruff check --select TC,FA --fix --unsafe-fixes .
py-format-annotation-imports: ruff format --select TC,FA --fix --unsafe-fixes .

They basically import statements merely used for annotation only during type checking runs:

if TYPE_CHECKING: import AirFrobnicator from frobnication
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-06-02 20:21:28 +02:00
commit fdabca79e8
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -45,6 +45,16 @@ py-format-assignments:
-execdir /usr/bin/sed -i 's/^\(\s\+[a-zA-Z0-9_]\+\)=\([^,[:space:]]\+\)\([,(]\)*\s*$$/\1 = \2\3/g' {} '+'
git diff --exit-code
py-check-annotation-imports:
ifneq ($(PY_CHECK_RUFF),)
$(PY_CHECK_RUFF) check --select TC,FA --diff --unsafe-fixes .
endif
py-format-annotation-imports:
ifneq ($(PY_CHECK_RUFF),)
$(PY_CHECK_RUFF) check --select TC,FA --fix --unsafe-fixes .
endif
clean.topdir: clean.py-check
clean.py-check:
rm -rf .mypy_cache