Skip to content

Commit 36aa406

Browse files
authored
Fix 1840 (#1895)
* start new dev branch; add audit file * Add ruff ANN/UP/TCH annotation checks to check-typing (#1840) The check-typing recipe now runs `ruff check --select ANN,UP,TCH` (annotation presence, pyupgrade modern syntax, TYPE_CHECKING imports) on src/autobahn/ before the ty check, so annotation/style regressions are caught in the CI quality-checks job. src/autobahn/ currently has ~3800 missing-annotation findings, so the ANN codes (and the 3 TC00x currently present) are ratcheted via an explicit --ignore allowlist to be removed module-by-module (#1839); every other UP and TC rule is enforced immediately. Generated code (flatbuffers/, wamp/gen/, message_fbs.py) is excluded via [tool.ruff] plus --force-exclude. Deviation from the issue as written: the annotation rules are scoped to this recipe via the command-line --select rather than the global [tool.ruff.lint] select, because check-format runs `ruff check .` off that config and would otherwise turn red with all ~3800 findings. The proposed `required-imports = ["from __future__ import annotations"]` is also omitted (it is the eager annotation-eval hazard behind #1878). Only the safe [tool.ruff.lint.flake8-annotations] tuning was added to pyproject.toml. check-typing now also depends on (install-tools venv) so the venv ruff is present when run standalone. Verified green end-to-end (ruff + ty) on cpy311. Note: This work was completed with AI assistance (Claude Code).
1 parent 20821ab commit 36aa406

4 files changed

Lines changed: 31 additions & 1 deletion

File tree

.audit/oberstet_fix_1840.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- [ ] I did **not** use any AI-assistance tools to help create this pull request.
2+
- [x] I **did** use AI-assistance tools to *help* create this pull request.
3+
- [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.
4+
5+
Submitted by: @oberstet
6+
Date: 2026-07-01
7+
Related issue(s): #1840
8+
Branch: oberstet:fix_1840

docs/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Changelog
1616
**Build & CI/CD**
1717

1818
* 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)
19+
* 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)
1920

2021
26.6.2
2122
------

justfile

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ check-format venv="": (install-tools venv)
730730
# Run static type checking with ty (Astral's Rust-based type checker)
731731
# FIXME: Many type errors need to be fixed. For now, we ignore most rules
732732
# to get CI passing. Create follow-up issue to address type errors.
733-
check-typing venv="": (install venv)
733+
check-typing venv="": (install venv) (install-tools venv)
734734
#!/usr/bin/env bash
735735
set -e
736736
VENV_NAME="{{ venv }}"
@@ -740,6 +740,20 @@ check-typing venv="": (install venv)
740740
echo "==> Defaulting to venv: '${VENV_NAME}'"
741741
fi
742742
VENV_PATH="{{ VENV_DIR }}/${VENV_NAME}"
743+
echo "==> Checking type annotation presence and modern syntax (via ruff)..."
744+
# Annotation presence (ANN), modern syntax (UP/pyupgrade) and TYPE_CHECKING
745+
# imports (TC). The ANN/TC ignores below track the EXISTING gaps in src/autobahn/
746+
# and should be removed module-by-module as typing improves (see #1839); every
747+
# other UP and TC rule is enforced now, so new code cannot regress modern syntax.
748+
# Generated code is skipped via the [tool.ruff] exclude list; --force-exclude makes
749+
# that apply to the explicit src/autobahn/ path too.
750+
"${VENV_PATH}/bin/ruff" check --select ANN,UP,TCH --force-exclude \
751+
--ignore ANN001 --ignore ANN002 --ignore ANN003 \
752+
--ignore ANN201 --ignore ANN202 --ignore ANN204 --ignore ANN205 --ignore ANN206 \
753+
--ignore ANN401 \
754+
--ignore UP037 \
755+
--ignore TC001 --ignore TC002 --ignore TC003 \
756+
src/autobahn/
743757
echo "==> Running static type checks with ty (using ${VENV_NAME} for type stubs)..."
744758
# Note: Only check src/autobahn/, not src/flatbuffers/ (generated code)
745759
# FIXME: Many ignores needed until type annotations are fixed

pyproject.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,3 +381,10 @@ docstring-code-line-length = "dynamic"
381381

382382
[tool.ruff.lint.pydocstyle]
383383
convention = "google" # Accepts: "google", "numpy", or "pep257".
384+
385+
# Shapes the flake8-annotations (ANN) rules that `just check-typing` selects on the
386+
# command line (see #1839). Inert for `check-format`, which does not select ANN.
387+
[tool.ruff.lint.flake8-annotations]
388+
mypy-init-return = true # allow __init__ without an explicit -> None
389+
suppress-none-returning = false # still require -> None on functions returning only None
390+
allow-star-arg-any = false # *args/**kwargs must be typed, not implicitly Any

0 commit comments

Comments
 (0)