Ship py.typed marker and enforce pyright baseline gate - #179
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
tmgbedu
commented
Jul 16, 2026
tmgbedu
left a comment
Contributor
Author
There was a problem hiding this comment.
[Code Reviewer verdict: APPROVE — GitHub blocked formal approval since the reviewing account is also the PR author; posting as a comment instead.]
Reviewed the diff, read scripts/check_types.py in full, confirmed CI wiring in .github/workflows/lint.yml, and ran the gate locally against the PR branch (matches pyright's own --outputjson errorCount of 659).
py.typed vs check_types.py — not redundant, different problems:
py.typedis a pure PEP 561 packaging marker. It only affects downstream consumers of the published package (their type checkers stop emittingreportMissingTypeStubswhen importingfastapi_startkit). It enforces nothing in this repo's own CI.check_types.pysolves an orthogonal problem: turning this repo's own advisory pyright job into a blocking one without breaking CI on the pre-existing 659 errors. These two changes are independently justified; neither makes the other unnecessary.
Could the gate be simpler (inline YAML / pyproject / plain pyright CLI)?
- Plain
uv run pyright(no gate) isn't viable yet — it would fail immediately on the 659 pre-existing basic-mode errors documented in the PR. - Pyright has no built-in baseline/ratchet feature (unlike e.g. ESLint's warning caps), so "enforce only regressions" can't be expressed via pyright config or pyproject.toml alone.
- An inline bash/jq one-liner in the YAML could replace the script, but it trades a small (64-line), typed, locally-runnable, single-purpose script for a less readable/testable shell fragment embedded in YAML, with no real reduction in what's being enforced. The script is also runnable locally via
uv run python scripts/check_types.py, matching CI exactly. - Verdict: keep the script — it's the simplest reasonable way to implement the stated ratchet behavior, and it's correctly wired (
working-directory: fastapi_startkit, baseline path resolved viaPath(__file__).with_name(...)so it's CWD-independent).
Verification performed:
uv run python scripts/check_types.pyon the PR branch → "OK: pyright errors at baseline (659)."- Directly ran
uv run pyright --outputjson→summary.errorCount == 659, confirming the script reads the right field and the baseline file is accurate. - Confirmed
uv's own stderr warnings (e.g. VIRTUAL_ENV mismatch noise) do not leak into stdout, soproc.stdout.find("{")reliably locates the JSON blob in practice.
Minor, non-blocking suggestions:
proc.stdout.find("{")JSON-extraction heuristic is slightly fragile in theory; empirically safe since uv's warnings go to stderr and pyright's--outputjsonwrites pure JSON to stdout. Could harden later with plainjson.loads(proc.stdout).- No unit test for
check_types.pyitself (covering the >, <, == branches). First script underscripts/, so no existing convention violated, but worth adding for future-proofing.
Neither blocks approval.
Add a PEP 561 py.typed marker so downstream type checkers honour the package's inline hints instead of reporting reportMissingTypeStubs when importing fastapi_startkit.
tmgbedu
force-pushed
the
task/py-typed-static-gate-1053
branch
from
July 16, 2026 08:08
b44607b to
4c0a87d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes
reportMissingTypeStubsfor consumers importingfastapi_startkit(e.g.fastapi_startkit.fastapi) and turns the advisory pyright CI job into an enforced, regression-proof gate.Changes
src/fastapi_startkit/py.typed— PEP 561 marker so type checkers trust the package's inline hints. Verified present in the built wheel (fastapi_startkit/py.typed).scripts/check_types.py— a baseline gate. Runs pyright and compares the error count toscripts/pyright_baseline.txt:scripts/pyright_baseline.txt— current baseline659(basic mode, unchanged).lint.yml— pyright job is now blocking and runs the gate instead ofcontinue-on-error.Why a baseline gate
The package currently has 659 pyright errors in
basicmode, so flipping to fully-blocking would break CI. The gate grandfathers existing debt while preventing any new type errors, and ratchets down as errors are fixed.Testing
uv build --wheel→ confirmedfastapi_startkit/py.typedinside the wheel.Notes:
basicmode retained per decision; no source type fixes in this PR (baseline only).