diff --git a/.audit/oberstet_fix_1840.md b/.audit/oberstet_fix_1840.md new file mode 100644 index 000000000..79d7c028a --- /dev/null +++ b/.audit/oberstet_fix_1840.md @@ -0,0 +1,8 @@ +- [ ] I did **not** use any AI-assistance tools to help create this pull request. +- [x] I **did** use AI-assistance tools to *help* create this pull request. +- [x] I have read, understood and followed the projects' [AI Policy](https://github.com/crossbario/autobahn-python/blob/main/AI_POLICY.md) when creating code, documentation etc. for this pull request. + +Submitted by: @oberstet +Date: 2026-07-01 +Related issue(s): #1840 +Branch: oberstet:fix_1840 diff --git a/docs/changelog.rst b/docs/changelog.rst index 31610a383..ef11b2707 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -16,6 +16,7 @@ Changelog **Build & CI/CD** * Add CalVer / PEP 440 version-management ``just`` recipes (``file-version``, ``bump-dev``, ``bump-next``, ``prep-release``) mirroring Crossbar.io, and document the versioning policy in ``CONTRIBUTING.md`` (#1894) +* Add ``ruff check --select ANN,UP,TCH`` (annotation presence, ``pyupgrade`` modern syntax, ``TYPE_CHECKING`` imports) to the ``just check-typing`` recipe so annotation/style regressions are caught in the ``quality-checks`` CI job. The existing gaps in ``src/autobahn/`` are ratcheted via an explicit ``--ignore`` allowlist to be removed module-by-module (#1839); all other ``UP``/``TC`` rules are enforced immediately, and generated code is excluded. The annotation rules are scoped to this recipe via the command line rather than the global ``[tool.ruff.lint]`` select, so the repo-wide ``check-format`` gate is unaffected (#1840) 26.6.2 ------ diff --git a/justfile b/justfile index bcf3adae6..c47dd0bc9 100644 --- a/justfile +++ b/justfile @@ -730,7 +730,7 @@ check-format venv="": (install-tools venv) # Run static type checking with ty (Astral's Rust-based type checker) # FIXME: Many type errors need to be fixed. For now, we ignore most rules # to get CI passing. Create follow-up issue to address type errors. -check-typing venv="": (install venv) +check-typing venv="": (install venv) (install-tools venv) #!/usr/bin/env bash set -e VENV_NAME="{{ venv }}" @@ -740,6 +740,20 @@ check-typing venv="": (install venv) echo "==> Defaulting to venv: '${VENV_NAME}'" fi VENV_PATH="{{ VENV_DIR }}/${VENV_NAME}" + echo "==> Checking type annotation presence and modern syntax (via ruff)..." + # Annotation presence (ANN), modern syntax (UP/pyupgrade) and TYPE_CHECKING + # imports (TC). The ANN/TC ignores below track the EXISTING gaps in src/autobahn/ + # and should be removed module-by-module as typing improves (see #1839); every + # other UP and TC rule is enforced now, so new code cannot regress modern syntax. + # Generated code is skipped via the [tool.ruff] exclude list; --force-exclude makes + # that apply to the explicit src/autobahn/ path too. + "${VENV_PATH}/bin/ruff" check --select ANN,UP,TCH --force-exclude \ + --ignore ANN001 --ignore ANN002 --ignore ANN003 \ + --ignore ANN201 --ignore ANN202 --ignore ANN204 --ignore ANN205 --ignore ANN206 \ + --ignore ANN401 \ + --ignore UP037 \ + --ignore TC001 --ignore TC002 --ignore TC003 \ + src/autobahn/ echo "==> Running static type checks with ty (using ${VENV_NAME} for type stubs)..." # Note: Only check src/autobahn/, not src/flatbuffers/ (generated code) # FIXME: Many ignores needed until type annotations are fixed diff --git a/pyproject.toml b/pyproject.toml index 9ed5f4f26..ac7acc00f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -381,3 +381,10 @@ docstring-code-line-length = "dynamic" [tool.ruff.lint.pydocstyle] convention = "google" # Accepts: "google", "numpy", or "pep257". + +# Shapes the flake8-annotations (ANN) rules that `just check-typing` selects on the +# command line (see #1839). Inert for `check-format`, which does not select ANN. +[tool.ruff.lint.flake8-annotations] +mypy-init-return = true # allow __init__ without an explicit -> None +suppress-none-returning = false # still require -> None on functions returning only None +allow-star-arg-any = false # *args/**kwargs must be typed, not implicitly Any