Context
While working on CI hardening (feat/ci-hardening), we attempted to enable ruff check --select ALL across the Python codebase. All three Python files surfaced violations that could not be addressed through incremental patching — the code structure itself makes clean compliance impractical.
- Broad
except Exception clauses throughout (BLE001)
- Missing type annotations on most functions and methods (ANN001/ANN202/ANN204)
- Missing or malformed docstrings across all classes and methods (D101/D102/D107)
print() calls instead of structured logging (T201)
os.path instead of pathlib (PTH109/PTH112/PTH118)
- Mutable class-level attributes without
ClassVar annotation (RUF012)
- Complexity violations in
_populate_commands and _spawn_subprocess (C901/PLR0912/PLR0915)
try/except/pass patterns that silently swallow errors (SIM105/S110)
- Inline
try/except on single lines (E701)
- Private member access across class boundaries —
self.app._log_line (SLF001)
Proposal
All three files would benefit from a clean rewrite following current Python best practices:
from __future__ import annotations + full type annotations
logging module replacing all print() calls
pathlib.Path throughout
- Specific exception types everywhere
contextlib.suppress() where appropriate
- Docstrings on all public classes and methods
ClassVar annotations on class-level mutables
- Helper methods to keep function complexity below threshold
This would also make the CI gate (ruff check --select ALL) unconditionally green, which is the goal of feat/ci-hardening.
Files concerned
range42-context-tui.py
range42-init.py
wizard/preflight.py
Context
While working on CI hardening (
feat/ci-hardening), we attempted to enableruff check --select ALLacross the Python codebase. All three Python files surfaced violations that could not be addressed through incremental patching — the code structure itself makes clean compliance impractical.except Exceptionclauses throughout (BLE001)print()calls instead of structured logging (T201)os.pathinstead ofpathlib(PTH109/PTH112/PTH118)ClassVarannotation (RUF012)_populate_commandsand_spawn_subprocess(C901/PLR0912/PLR0915)try/except/passpatterns that silently swallow errors (SIM105/S110)try/excepton single lines (E701)self.app._log_line(SLF001)Proposal
All three files would benefit from a clean rewrite following current Python best practices:
from __future__ import annotations+ full type annotationsloggingmodule replacing allprint()callspathlib.Paththroughoutcontextlib.suppress()where appropriateClassVarannotations on class-level mutablesThis would also make the CI gate (
ruff check --select ALL) unconditionally green, which is the goal offeat/ci-hardening.Files concerned
range42-context-tui.pyrange42-init.pywizard/preflight.py