Summary
Enhance the just check-typing recipe to include ruff check --select ANN,UP alongside the existing ty check, making it easier for contributors to validate type annotations locally before pushing.
This was suggested by @bblommers in PR #1838 and aligns with the typed subset initiative in #1839.
Current State
justfile check-typing recipe
Currently only runs ty check with many --ignore flags:
ty check \
--python "${VENV_PATH}/bin/python" \
--ignore unresolved-import \
--ignore unresolved-attribute \
--ignore unresolved-reference \
--ignore possibly-missing-attribute \
--ignore call-non-callable \
--ignore invalid-assignment \
--ignore invalid-argument-type \
--ignore invalid-method-override \
--ignore invalid-type-form \
--ignore unsupported-operator \
--ignore too-many-positional-arguments \
--ignore unknown-argument \
--ignore not-subscriptable \
--ignore not-iterable \
--ignore no-matching-overload \
--ignore conflicting-declarations \
src/autobahn/
Missing: ruff check --select ANN,UP for annotation presence and modern syntax.
CI workflow (main.yml)
The quality-checks job runs:
just check-format cpy314 — ruff formatting/linting
just check-typing cpy314 — ty type checking
Once we update the check-typing recipe, CI will automatically pick up the changes.
Proposed Changes
1. Add ruff annotation checks to check-typing
# Add before ty check:
echo "==> Checking type annotation presence and style (via ruff)..."
ruff check --select ANN,UP,TCH src/autobahn/
echo "==> Running static type checks (via ty)..."
ty check ...
Rule sets:
| Rule |
Purpose |
ANN |
flake8-annotations — missing type annotations |
UP |
pyupgrade — modernize syntax (Optional → X | None, etc.) |
TCH |
flake8-type-checking — proper TYPE_CHECKING imports |
2. Configure ruff in pyproject.toml
Add/update ruff configuration to match the style guide from #1839:
[tool.ruff]
target-version = "py311"
line-length = 120
[tool.ruff.lint]
select = [
"ANN", # flake8-annotations
"I", # isort
"E", # pycodestyle errors
"F", # pyflakes
"W", # pycodestyle warnings
"UP", # pyupgrade
"TCH", # flake8-type-checking
]
[tool.ruff.lint.flake8-annotations]
mypy-init-return = true
suppress-none-returning = false
allow-star-arg-any = false
[tool.ruff.lint.isort]
required-imports = ["from __future__ import annotations"]
3. Gradual ignore removal
The current ty check has many --ignore flags with a FIXME comment. As typing coverage improves per #1839, these should be progressively removed:
Phase 1 (now): Add ruff ANN,UP,TCH checks (may need --ignore initially)
Phase 2 (ongoing): As modules get typed, remove corresponding --ignore flags
Phase 3 (goal): Zero ignores — full strict mode
4. Verify CI integration
After updating check-typing, verify that:
Implementation Notes
Option A: Strict from the start
- Run
ruff check --select ANN,UP,TCH without ignores
- Fix all violations before merging
- Cleaner but more work upfront
Option B: Gradual adoption
- Add ruff checks with
--ignore for specific rules initially
- Remove ignores as files are typed
- Matches the "piece by piece" approach
Recommend Option B to avoid blocking on full codebase typing.
Acceptance Criteria
Related
References
Checklist
Summary
Enhance the
just check-typingrecipe to includeruff check --select ANN,UPalongside the existingty check, making it easier for contributors to validate type annotations locally before pushing.This was suggested by @bblommers in PR #1838 and aligns with the typed subset initiative in #1839.
Current State
justfile
check-typingrecipeCurrently only runs
ty checkwith many--ignoreflags:ty check \ --python "${VENV_PATH}/bin/python" \ --ignore unresolved-import \ --ignore unresolved-attribute \ --ignore unresolved-reference \ --ignore possibly-missing-attribute \ --ignore call-non-callable \ --ignore invalid-assignment \ --ignore invalid-argument-type \ --ignore invalid-method-override \ --ignore invalid-type-form \ --ignore unsupported-operator \ --ignore too-many-positional-arguments \ --ignore unknown-argument \ --ignore not-subscriptable \ --ignore not-iterable \ --ignore no-matching-overload \ --ignore conflicting-declarations \ src/autobahn/Missing:
ruff check --select ANN,UPfor annotation presence and modern syntax.CI workflow (main.yml)
The
quality-checksjob runs:just check-format cpy314— ruff formatting/lintingjust check-typing cpy314— ty type checkingOnce we update the
check-typingrecipe, CI will automatically pick up the changes.Proposed Changes
1. Add ruff annotation checks to
check-typingRule sets:
ANNUPOptional→X | None, etc.)TCHTYPE_CHECKINGimports2. Configure ruff in pyproject.toml
Add/update ruff configuration to match the style guide from #1839:
3. Gradual ignore removal
The current
ty checkhas many--ignoreflags with a FIXME comment. As typing coverage improves per #1839, these should be progressively removed:Phase 1 (now): Add ruff
ANN,UP,TCHchecks (may need--ignoreinitially)Phase 2 (ongoing): As modules get typed, remove corresponding
--ignoreflagsPhase 3 (goal): Zero ignores — full strict mode
4. Verify CI integration
After updating
check-typing, verify that:just check-typing cpy314passes locallyquality-checksjob runs the updated recipeImplementation Notes
Option A: Strict from the start
ruff check --select ANN,UP,TCHwithout ignoresOption B: Gradual adoption
--ignorefor specific rules initiallyRecommend Option B to avoid blocking on full codebase typing.
Acceptance Criteria
just check-typingruns bothruff check --select ANN,UP,TCHandty checkpyproject.tomlhas ruff configuration matching style guidequality-checksjob passes with updated recipeRelated
References
Checklist