Repository navigation
fix: add a mypy gate for jq_collector and fix what it found (#38) - #44
Merged
Merged
Conversation
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.
Fixes #38
Acceptance criterion (verbatim):
What changed
The gate
collector/pyproject.toml:mypyandtypes-PyYAMLadded to thedevgroup (uv.lockrelocked), and a[tool.mypy]table withfiles = ["jq_collector"]andpython_version = "3.11"(therequires-pythonfloor). Default strictness, not--strict, per the issue's "start non-strict"..github/workflows/ci.yml: a Types step,uv run --frozen mypy, in thecollector (lint + tests)job. It passes no flags; scope comes from the config.The 12 errors mypy found on
main, fixed with annotations and no# type: ignore:github.py/gitlab.py:**params: object→ httpxparams(2 errors)**params: str | inton all 7 helpers; every call site passes a str or an intlocalgit.py:**dict[str, object]intoLocalRepo(4)_measurementsreturns a_MeasuredTypedDict naming exactly the fields it fillsmetrics.py:objectassigned toWorkflowRun(1)unique: dict[str, WorkflowRun]__main__.py: invariantdictpassed tocollect(2)coverage_cacheannotated with the typecollectdeclaresgithub.pylatest_runs:objecthas no.get(3)isinstance(…, dict)narrowing, as every other_jsoncall site in the file already does; keys typedAny(they're JSON values)One behaviour change, deliberately: in
latest_runs, a response that parses as JSON but isn't an object (e.g. a list) used to raiseAttributeErrorand error the whole repo for that refresh. It's now treated like a missing feed. That matches how the other twenty-odd_jsoncall sites ingithub.py/gitlab.pytreat a malformed response. Nothing else changes at runtime.Checks (run locally from
collector/, as CI does)uv run --frozen ruff check jq_collector tests: passuv run --frozen ruff format --check jq_collector tests: passuv run --frozen mypy: Success: no issues found in 11 source filesdef _broken() -> int: return "not an int"added toforge.py,uv run --frozen mypyexits 1 and reports thereturn-valueerror. So a type error fails the step.Not addressed
--strict(ordisallow_untyped_defs) is left for later. For example,metrics.renderstill has no return annotation.tests/isn't type-checked; the config scopes mypy to the package.Closes #38
🤖 Generated with Claude Code