Skip to content

Lint and type-check the Python tools in CI with a ratchet (ruff, pyright) - #323

Closed
v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:ci-lint-python
Closed

v0lumehi wants to merge 1 commit into
seedds:mainfrom
v0lumehi:ci-lint-python

Conversation

@v0lumehi

@v0lumehi v0lumehi commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Part of the roadmap in #313 (code quality checks in CI).

The Python toolchain (dmsh_build.py, scripts/build_ipa_from_nsp.py, the shader split and its container readers, bench.py) has had no linter and no type checker so far. A typo in a branch that is rarely taken shows up only when someone builds exactly that case.

What this adds

  • .github/workflows/lint-python.yml runs ruff and pyright on every PR and on pushes to main.
    • ruff uses bug-finding rules only, with no formatting, so no existing code changes.
    • pyright runs in basic mode.
    • Both cover scripts/, dm/tools, dm/gfx/tools, dm/games/*.py, dm/ios/tools and dm/mac. They are configured in pyproject.toml, and their versions are pinned in .github/requirements/lint.txt.
  • A ratchet, so nothing goes red today.
    • Today's 414 findings (35 ruff, 379 pyright) are listed in dm/tools/lint_python_baseline.tsv. Each entry is keyed by tool, file, rule and message, with a count, so the entries survive line moves.
    • dm/tools/lint_python.py fails on a finding beyond the baseline, and on a fixed one that is still listed.
    • --update only shrinks the baseline. On pull requests, --against fails when the baseline grew over the base branch's.
    • Only a raised tool version rewrites the baseline.
  • Astral's ty, a faster type checker from the makers of ruff, can replace pyright in a later PR once it is stable (it is in beta today).
  • docs/development.md (continuous integration) says how to run the check locally and how to refresh the baseline.

Checked

  • python3 dm/tools/lint_python.py: 414 findings, 414 in the baseline, 0 new, 0 fixed but still listed.
  • test_docs passes.

The existing findings are not fixed here. They are follow-ups, each one a small PR that shrinks the baseline.

Add .github/workflows/lint-python.yml: ruff (bug-finding rules only, no
formatting) and pyright in basic mode over scripts/, dm/tools, dm/gfx/tools,
dm/games/*.py, dm/ios/tools and dm/mac, configured in pyproject.toml, with
the tool versions pinned in .github/requirements/lint.txt.

Today's 414 findings (35 ruff, 379 pyright) are listed in
dm/tools/lint_python_baseline.tsv, keyed by tool, file, rule and message
with a count, so they survive line moves. dm/tools/lint_python.py fails on
a finding beyond the baseline and on a fixed one still listed; --update
only shrinks the baseline, and on pull requests --against fails when it
grew over the base branch's. Only a raised tool version rewrites it.

Astral's ty, a faster type checker, can replace pyright once it is stable.
@v0lumehi v0lumehi changed the title Lint and type-check the Python tools in CI with a ratchet (ruff, pyright; ty advisory) Lint and type-check the Python tools in CI with a ratchet (ruff, pyright) Oct 26, 2026
seedds added a commit that referenced this pull request Oct 26, 2026
Add pinned ruff and pyright checks, the existing-findings baseline, and a
workflow that rejects new findings and requires fixed findings to be removed.

Compare checker pins numerically and permit baseline growth only for the
checker whose release version increased. Comments, unrelated dependency
edits and downgrades retain the guard. Add 10 regression tests using Git
trees and document the policy.

Validation: 14 guard/documentation tests pass; pinned lint reports 414
existing findings, zero new findings and zero stale baseline entries.

Co-authored-by: v0lumehi <aljic.zijad@gmail.com>
@seedds

seedds commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Landed this on main in 7f5ef41, with @v0lumehi credited as coauthor.

The integration also tightens the baseline guard: it compares the ruff and pyright release pins numerically and allows growth only for the checker whose version increased. Comment edits, unrelated dependency changes and checker downgrades cannot bypass the guard. Added 10 regression tests using temporary Git trees and documented the policy.

Validation on top of current main: all 14 guard/documentation tests passed, the pinned ruff/pyright check reported 414 existing findings with zero new or stale findings, and git diff --check passed. The original baseline is unchanged.

Closing this PR because the changes have landed. Thanks for the contribution.

@seedds seedds closed this Oct 26, 2026
@v0lumehi
v0lumehi deleted the ci-lint-python branch October 26, 2026 19:41
v0lumehi added a commit to v0lumehi/nxnative that referenced this pull request Oct 26, 2026
Modules loaded from files go through one helper that checks the spec, the
closures bind their loop variables, the f-strings parse on Python 3.10, and the
frame-time comparisons check for missing values.
Know-It-All-Brother pushed a commit to Know-It-All-Brother/nxnative that referenced this pull request Nov 9, 2026
…dds#323)

Add pinned ruff and pyright checks, the existing-findings baseline, and a
workflow that rejects new findings and requires fixed findings to be removed.

Compare checker pins numerically and permit baseline growth only for the
checker whose release version increased. Comments, unrelated dependency
edits and downgrades retain the guard. Add 10 regression tests using Git
trees and document the policy.

Validation: 14 guard/documentation tests pass; pinned lint reports 414
existing findings, zero new findings and zero stale baseline entries.

Co-authored-by: v0lumehi <aljic.zijad@gmail.com>
ltrdpper pushed a commit to ltrdpper/BananaNative that referenced this pull request Nov 16, 2026
…read take a free one it reads, in the order they press' (seedds#323) from Wick3dPhant0m/BananaNative:pad-fill into android
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants