From fdabca79e8166af16ceec5dcd940cc7c88dca650 Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Tue, 2 Jun 2026 20:21:28 +0200 Subject: [PATCH] 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 --- make/py-topdir.mk | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/make/py-topdir.mk b/make/py-topdir.mk index 377bad28..817a740b 100644 --- a/make/py-topdir.mk +++ b/make/py-topdir.mk @@ -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