Blocked by #1156, #1167, #1178 (stacked PRs touching the same files — do the sweep on main after they merge).
Vectorization handles ternary expressions (ttsim.tt.vectorization converts ast.IfExp to xnp.where via _ifexp_to_call), but pyproject.toml ignores SIM108 for src/gettsim/germany/* with the incorrect justification "vectorization requires if/else blocks". Context: #1178 (comment)
Tasks
-
Remove the "SIM108" line from per-file-ignores."src/gettsim/germany/*" in pyproject.toml. Keep "RET" and the other ignores — the return-pattern restrictions are real.
-
Convert all 7 violations to ternaries (list via ruff check --isolated --select SIM108 src/gettsim/germany/):
einkommensteuer/abzüge/alleinerziehend.py:14
einkommensteuer/abzüge/vorsorge.py:113
elterngeld/elterngeld.py:92
erziehungsgeld/erziehungsgeld.py:72
ids.py:119, ids.py:278
kinderbonus/kinderbonus.py:15
Ruff marks these fixes unsafe because of comments inside branches — apply manually and keep the comments (move them above the assignment). No noqas: ruff already skips sites where the ternary would exceed the line limit.
-
Update docs to recommend ternaries for single-assignment branches (statement if/elif/else remains for nested/multi-branch logic):
docs/gettsim_developer/code-restrictions.md (currently only lists one-line if-else as "allowed")
AGENTS.md, section "Code Restrictions for Vectorization"
Acceptance criteria
pixi run prek run --all-files passes with the ignore removed.
- Pure refactor:
pixi run ty, pixi run ty-jax, and the full test suite (pixi run -e py314-jax tests -n 7) pass unchanged.
Blocked by #1156, #1167, #1178 (stacked PRs touching the same files — do the sweep on
mainafter they merge).Vectorization handles ternary expressions (
ttsim.tt.vectorizationconvertsast.IfExptoxnp.wherevia_ifexp_to_call), butpyproject.tomlignores SIM108 forsrc/gettsim/germany/*with the incorrect justification "vectorization requires if/else blocks". Context: #1178 (comment)Tasks
Remove the
"SIM108"line fromper-file-ignores."src/gettsim/germany/*"inpyproject.toml. Keep"RET"and the other ignores — the return-pattern restrictions are real.Convert all 7 violations to ternaries (list via
ruff check --isolated --select SIM108 src/gettsim/germany/):einkommensteuer/abzüge/alleinerziehend.py:14einkommensteuer/abzüge/vorsorge.py:113elterngeld/elterngeld.py:92erziehungsgeld/erziehungsgeld.py:72ids.py:119,ids.py:278kinderbonus/kinderbonus.py:15Ruff marks these fixes unsafe because of comments inside branches — apply manually and keep the comments (move them above the assignment). No
noqas: ruff already skips sites where the ternary would exceed the line limit.Update docs to recommend ternaries for single-assignment branches (statement
if/elif/elseremains for nested/multi-branch logic):docs/gettsim_developer/code-restrictions.md(currently only lists one-line if-else as "allowed")AGENTS.md, section "Code Restrictions for Vectorization"Acceptance criteria
pixi run prek run --all-filespasses with the ignore removed.pixi run ty,pixi run ty-jax, and the full test suite (pixi run -e py314-jax tests -n 7) pass unchanged.