ci: add ty type checking (warn-first ratchet)#1286
Merged
Conversation
Introduces Astral's `ty` as the project type checker (replacing the unused `mypy` dev dependency). Phase 1 made the schema unions statically visible, which is what makes type checking useful here at all. ty is beta (0.0.x, diagnostics may change between versions), so it is pinned via uv.lock and CI uses the locked version — same discipline as ruff. Rollout is broad-scope, warn-first: ty runs over all of `core/`, but the ~16 rules that currently fire on the legacy code are downgraded to non-blocking `warn` in [tool.ty.rules], while every other ty rule is enforced at `error`. The new typecheck workflow runs `ty check --exit-zero-on-warning`, so warnings are visible in the logs but green, and any error-level diagnostic fails CI. 296 diagnostics today (0 error-level after the warn config). The ratchet is to fix a rule's instances and flip it back to `error`, one rule at a time — the biggest, `unresolved-attribute` (138), is mostly the ArangoYetiConnector mixin pattern and can be fixed at the root. - ty>=0.0.59 in the dev group; mypy removed; relocked - [tool.ty]: python-version 3.13, src.include=["core"], 16 warn rules - .github/workflows/typecheck.yml: full `uv sync --group dev` (ty needs real dependency types) + `uv run ty check --exit-zero-on-warning`
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
Adds Astral's
tyas the project type checker, replacing the unusedmypydev dependency. Phase 1 (static schema unions, #1285) is what makes type checking actually useful here — before it, every-> ObservableTypeswas statically an empty tuple.tyis beta (0.0.x — "diagnostics may change between any two versions"), so it's pinned via uv.lock and CI uses the locked version, exactly like ruff. Bumping it is a deliberate lockfile change.Rollout: broad scope, warn-first
ty runs over all of
core/. The ~16 rules that currently fire on the (previously un-type-checked) legacy code are downgraded to non-blockingwarnin[tool.ty.rules], while every other ty rule stays enforced aterror. CI runsty check --exit-zero-on-warning:296 diagnostics today, 0 error-level after the warn config. The ratchet is to fix a rule's instances and flip it back to
error, one rule at a time.What's here
ty>=0.0.59in thedevgroup;mypyremoved; relocked.[tool.ty]:python-version = "3.13",src.include = ["core"], and the 16 warn rules (each annotated with its current count)..github/workflows/typecheck.yml: fulluv sync --group dev(ty needs real dependency types — pydantic/fastapi/arango) +uv run ty check --exit-zero-on-warning.Ratchet backlog (follow-up PRs)
unsupported-operator(15) — includes genuinex not in Nonebugs (e.g.users.py:232). Fix + flip to error.unresolved-attribute(138) is mostly ONE root cause: theYetiTagModel/YetiContextModel/YetiAclModelmixins callself.save()/self.neighbors()/self.extended_id, which only exist once combined withArangoYetiConnector. Fixable at the root with aTYPE_CHECKINGprotocol onYetiBaseModel— clears a large chunk cleanly.unresolved-import(3): boto3/tldextract/yara (env-dependent) — add to the typecheck env or allowlist.invalid-parameter-default(15): thearg: list = None→Optional[...]cleanup.src.includetoplugins/,yetictl/oncecore/is clean.