← AUTOMATER NEWSROOM

Astral releases ty 1.0, with a way to catch new Python type errors in CI

Astral now recommends its Python type checker for production. A preview diagnostic baseline lets teams flag new type errors in pull requests while they fix existing ones.

A main-branch baseline records an existing Python type diagnostic. On a pull request, ty filters the recorded diagnostic and reports the new one to CI.A main-branch baseline records an existing Python type diagnostic. On a pull request, ty filters the recorded diagnostic and reports the new one to CI.
A ty diagnostic baseline records existing findings. In this illustrative pull request, CI still fails on a new type error.

Astral released ty 1.0 on December 1, its first stable version of the Python type checker and language server. The company now recommends ty for production use. For Python teams reviewing patches from coding agents, a diagnostic baseline records findings already present on the main branch so CI can flag new type errors while the team works through the backlog. The baseline feature is still in preview, according to Astral’s release notes.

The ty 1.0.0 release page for the astral-sh/ty repository on GitHub.
Astral’s ty 1.0.0 release page on GitHub. · Original source

The distinction matters in a mixed-typing codebase. Say an agent changes a shared helper to return a string where callers expect an integer. Checking the project can surface the mismatch in a caller outside the changed files. But turning on a required check for the first time can leave every pull request red because of unrelated findings. Astral’s launch example shows a baseline saving one existing diagnostic while a second error introduced in the same file still fails the check. That makes it possible to adopt the checker without first clearing the entire backlog. Astral’s ty 1.0 announcement

Set the baseline on the main branch

Pin ty to version 1.0.0 in the environment that runs CI. Use the same dependencies and Python target when creating the baseline and when checking pull requests. Astral’s configuration reference documents how to set environment.python-version explicitly if the target would otherwise vary with the environment. To enable the baseline, add this setting to pyproject.toml, merging it into the existing [tool.ty] table if the project already has one. ty configuration reference

[tool.ty]
baseline = "ty-baseline.json"

From the project root on the main branch, run ty check --update-baseline and commit the generated JSON with the configuration. Run plain ty check in pull-request CI. Before making the job required, verify that the baseline allows the known findings on an unchanged checkout. Then introduce an unmistakable type mismatch in a checked file on a throwaway branch, such as returning a string literal from a function annotated to return int. Confirm that the job reports the new diagnostic and fails. By default, ty exits with code 1 for warnings as well as errors, so check the project’s severity settings when deciding what should block a merge. ty configuration reference

Treat changes to the baseline as changes to what CI will accept. If a patch introduces a type error and regenerates its own baseline, the new finding can disappear from the check. Ask reviewers to look at baseline additions explicitly, and refresh the file deliberately as the team fixes old findings. Astral says the baseline file format can change between releases because the feature is in preview. The stable release also introduces a versioning policy under which patch releases are limited to bug fixes and minor releases can change checking behavior in ways that introduce new errors. Review checker upgrades alongside any resulting baseline changes. ty configuration reference · Astral’s release notes

Measure the check on real pull requests

Astral reports that OpenAI’s migration yielded a 24× median type-checking speedup and reduced peak memory usage by 73%. In a separate Astral benchmark, ty was the fastest command-line checker on 16 of 18 ecosystem projects in uncached runs on an M3 Max. For a CI decision, measure elapsed check time on your own runners and compare the diagnostics on a few recent patches. Pay particular attention to errors your current checker caught and to disagreements in framework-heavy modules. Astral documents built-in support for Pydantic, Django, pytest, and attrs. Its Pydantic example shows ty flagging a string passed to a strict boolean field and warning when a constructor argument is discarded because the field uses an alias. Astral’s ty 1.0 announcement

Keep behavior tests in the same review loop. A patch can preserve every declared type and still calculate the wrong result. The baseline gives maintainers a way to require one additional signal on every patch while improving coverage over time. For a complementary example of checking what agent-written code actually does, see what Simon Willison’s Beep Locator teaches about acceptance tests.

Sources

  1. Release 1.0.0 · astral-sh/ty · GitHub
  2. ty 1.0: an extremely fast Python type checker and language server
  3. Configuration | ty