ty 1.0: Try It on a Project That Uses mypy
Run ty 1.0.0 and mypy 2.4.1 on the same code, see where they differ, check exit codes and old type-ignore comments, and diff what --fix and --add-ignore edit.
Astral's Python type checker ty reached 1.0.0 on December 1, 2026. If your project already runs mypy, do not swap one for the other yet: run both on the same code, write down the differences, then decide. The results below come from a small sample project (checked 2026-12-02 KST).
[1] Install with pinned versions. Create a virtual environment and pin ty to 1.0.0 and mypy to 2.4.1, the version tested here. If your project already uses another mypy version, pin that one for the comparison. In a real project, install its dependencies in the same environment. Run the commands below with that environment activated (source .venv/bin/activate). Under the versioning policy, patch releases are bug fixes, but minor releases change type-checking behavior and may report new type errors.
$ python -m venv .venv$ .venv/bin/pip install ty==1.0.0 mypy==2.4.1$ .venv/bin/ty --version$ .venv/bin/mypy --versionty 1.0.0mypy 2.4.1 (compiled: yes)[2] Run both tools on the same files. The sample is eight files under src/, with no configuration file. mypy first.
$ mypy src/untyped_body.py src/stale_ignore.py src/redundant_cast.py src/code_mismatch.py src/empty_tuple.py src/same_error.py src/clean.py src/rows.py; echo "exit=$?"src/same_error.py:6: error: Argument 1 to "parse_port" has incompatible type "str | None"; expected "str" [arg-type]src/code_mismatch.py:1: error: Incompatible types in assignment (expression has type "str", variable has type "int") [assignment]src/code_mismatch.py:1: note: Error code "assignment" not covered by "type: ignore[arg-type]" commentFound 2 errors in 2 files (checked 8 source files)exit=1The same list through ty:
$ ty check --output-format concise src/untyped_body.py src/stale_ignore.py src/redundant_cast.py src/code_mismatch.py src/empty_tuple.py src/same_error.py src/clean.py src/rows.py; echo "exit=$?"src/code_mismatch.py:1:13: error[invalid-assignment] Object of type `Literal["10"]` is not assignable to `int`src/empty_tuple.py:6:12: warning[redundant-condition] Object of type `tuple[int]` is always truthysrc/redundant_cast.py:5:12: warning[redundant-cast] Value is already of type `int`src/same_error.py:6:23: error[invalid-argument-type] Argument to function `parse_port` is incorrect: Expected `str`, found `str | None`src/untyped_body.py:2:12: error[unsupported-operator] Operator `+` is not supported between objects of type `Literal["port "]` and `Literal[8080]`Found 5 diagnosticsexit=1| File | Code | mypy default | ty default |
|---|---|---|---|
same_error.py | a value that may be None passed where str is expected | error | error |
code_mismatch.py | string assigned to an int variable, line ends with # type: ignore[arg-type] | error | error |
untyped_body.py | "port " + 8080 inside a function with no annotations | nothing | error |
redundant_cast.py | cast(int, ...) on a value that is already int | nothing | warning |
empty_tuple.py | if test on a tuple[int] | nothing | warning |
stale_ignore.py | # type: ignore[assignment] on a line with no error | nothing | nothing |
rows.py, clean.py | fetchall() return / clean code | nothing | nothing |
Of the files where the results differ, untyped_body.py and redundant_cast.py were missed because of mypy's defaults. The mypy docs say that without [--check-untyped-defs](https://mypy.readthedocs.io/en/stable/command_line.html) the bodies of unannotated functions are not checked, and ty's mypy migration guide says ty always checks them and this is not configurable. Redundant casts and unused ignore comments are opt-in in mypy through --warn-redundant-casts and --warn-unused-ignores. Here are four of the files again with those three flags on.
$ mypy --check-untyped-defs --warn-redundant-casts --warn-unused-ignores src/untyped_body.py src/stale_ignore.py src/redundant_cast.py src/clean.py; echo "exit=$?"src/redundant_cast.py:5: error: Redundant cast to "int" [redundant-cast]src/stale_ignore.py:1: error: Unused "type: ignore" comment [unused-ignore]src/untyped_body.py:2: error: Unsupported operand types for + ("str" and "int") [operator]Found 3 errors in 3 files (checked 4 source files)exit=1With the flags on, mypy catches both files. In the other direction, only mypy reports stale_ignore.py; ty does not (see step 4). empty_tuple.py still passes mypy with the same flags, so these three flags do not remove that difference.
$ mypy --check-untyped-defs --warn-redundant-casts --warn-unused-ignores src/empty_tuple.py; echo "exit=$?"Success: no issues found in 1 source fileexit=0Some ty rules are off by default and report once enabled. rows.py returns sqlite3's fetchall() (list[Any]) as list[str]; neither tool reported it by default, and ty check --warn unsound-return src/rows.py made ty emit an unsound-return warning (see step 4).
[3] Check the exit codes your CI will see. Only values that were actually run are listed.
| Command | Exit code |
|---|---|
ty check src/clean.py (no problems) | 0 |
ty check src/same_error.py (error) | 1 |
ty check src/redundant_cast.py (warning only) | 1 |
ty check --exit-zero-on-warning src/redundant_cast.py | 0 |
ty check --error-on-warning src/redundant_cast.py | 1 |
ty check --exit-zero src/same_error.py | 0 |
ty check --config-file badcfg/ty.toml src/clean.py (unknown setting) | 2 |
mypy src/clean.py / mypy src/same_error.py | 0 / 1 |
ty exits 1 even when there are only warnings, which matches the exit codes page. The internal-error code 101 was not reproduced. Use --exit-zero-on-warning if warnings should not fail CI. An invalid configuration file (a [nope] section) ends with ty failed … unknown field nope and exit code 2.
[4] Move settings and existing ignore comments. The ty equivalent of mypy's disable_error_code is <rule> = "ignore" under [tool.ty.rules], and the severities are ignore, warn and error. With this pyproject.toml, one rule is raised to an error and one is turned off:
[tool.ty.rules]unsound-return = "error"redundant-cast = "ignore"$ ty check --output-format concise; echo "exit=$?"src/rows.py:6:12: error[unsound-return] Unsound return statement: `list[Any]` is not a subtype of `list[str]`Found 1 diagnosticexit=1Existing # type: ignore comments behave differently depending on their form. The test line was size: int = "10" with only the trailing comment changed.
| Trailing comment | mypy | ty |
|---|---|---|
# type: ignore | hidden | hidden |
# type: ignore[assignment] | hidden | error reported |
# type: ignore[assignment, ty:invalid-assignment] | hidden | hidden |
# ty: ignore[invalid-assignment] | error reported | hidden |
A # type: ignore[assignment] that carries only a mypy code does not silence ty, in line with the suppression docs, which say codes without a ty: prefix are ignored. While both tools run, listing both codes ([assignment, ty:invalid-assignment]) satisfied both.
Comments left on a line with no error also depend on their form. By default, ty warns (exit code 1) about a comment with no code or with a ty: code. It does not report a comment that has only a mypy code. With --warn-unused-ignores, mypy reported all three as errors.
| Comment on a line with no error | ty default | mypy --warn-unused-ignores |
|---|---|---|
# type: ignore | warning unused-type-ignore-comment | error |
# type: ignore[assignment, ty:invalid-assignment] | warning naming 'ty:invalid-assignment' as unused | error |
# type: ignore[assignment] | nothing | error |
ty has no counterpart to mypy plugins. The migration guide says it "does not have an equivalent to mypy plugins" and lists built-in support for Pydantic, Django, attrs and pytest. If your project uses a mypy plugin, check whether the library is on that list, then compare the two tools' results side by side.
[5] Before suppressing everything in one pass, try it on a copy. --fix and --add-ignore edit your files in place. Make sure the working tree is clean (git status --short prints nothing), run them on a copy, and read the diff -u.
$ cp -r src copy_fix$ ty check --fix copy_fix; echo "exit=$?"$ diff -ru src copy_fix…Found 5 diagnostics (1 fixed, 4 remaining).exit=1diff -ru src/redundant_cast.py copy_fix/redundant_cast.py--- src/redundant_cast.py 2026-12-01 22:28:08.000000000 +0000+++ copy_fix/redundant_cast.py 2026-12-01 22:29:40.835460836 +0000@@ -2,4 +2,4 @@ def midpoint(start: int, end: int) -> int:- return cast(int, start + end) // 2+ return (start + end) // 2One line in redundant_cast.py was fixed and four diagnostics remain. The fix keeps the parentheses right, but it still rewrites code, so run your tests afterwards.
--add-ignore appends # ty: ignore[rule] to the diagnostics ty reports. This run used a fresh copy without --fix, so all five original diagnostics got a comment, warnings included. As the diff shows, it also covers lines that hide real bugs.
$ cp -r src copy_ign$ ty check --add-ignore copy_ign; echo "exit=$?"$ diff -ru src copy_ignAll checks passed!Added 5 ignore commentsexit=0…diff -ru src/same_error.py copy_ign/same_error.py--- src/same_error.py 2026-12-01 22:28:11.000000000 +0000+++ copy_ign/same_error.py 2026-12-01 22:29:40.900462155 +0000@@ -3,4 +3,4 @@ def load(env: dict[str, str]) -> int:- return parse_port(env.get("PORT"))+ return parse_port(env.get("PORT")) # ty: ignore[invalid-argument-type]…The same_error.py line is a genuine defect: if the PORT variable is missing, None is passed. After the comment is added, ty check prints All checks passed! with exit code 0. Running mypy on the same copy still reports that line. Read the diff line by line, and fix real defects instead of annotating them. The docs warn that a # ty: ignore without rule names can hide other errors on the same line, so keep the rule names.
A baseline avoids touching source files. It is a preview feature: the docs say the file format may change and that it needs ty 0.0.93 or later. On the copy, recording the five existing diagnostics makes the next run pass.
$ cp -r src copy_base$ ty check --update-baseline --baseline ty-baseline.json copy_base; echo "exit=$?"Updated baseline `/work/ty-baseline.json` with 5 diagnostics.exit=0$ ty check --baseline ty-baseline.json copy_base; echo "exit=$?"All checks passed!exit=0Add a file with a new error, and only that error is reported.
$ printf 'def new(x: int) -> str:\n return x\n' > copy_base/new_bug.py$ ty check --output-format concise --baseline ty-baseline.json copy_base; echo "exit=$?"copy_base/new_bug.py:2:12: error[invalid-explicit-return] Return type does not match returned value: expected `str`, found `int`Found 1 diagnosticexit=1An error recorded in the baseline is not fixed. Check for real defects before you record it.
[6] Set up CI. Pin versions with == and upgrade in a separate change. A minor release can add new errors, so review new diagnostics in the pull request that raises the pin, then fix them or record them in the baseline. Keep running mypy alongside for a while instead of dropping it.
If existing errors remain, a CI job with a plain ty check fails from day one. Fix them first, or commit a baseline you have reviewed. The check.sh below still runs mypy when ty fails, and exits 1 if either tool fails. Replace src with your project's path.
rc=0ty check --output-format concise --baseline ty-baseline.json src || rc=1mypy src || rc=1exit $rcThis was tested with sh check.sh in a folder holding only untyped_body.py and clean.py, after creating a baseline there. Both files pass mypy's defaults.
| State | ty | mypy | check.sh exit code |
|---|---|---|---|
| no new error | pass | pass | 0 |
| new error only ty reports | fail | pass | 1 |
| new error only mypy reports | pass | fail | 1 |
| new error both report | fail | fail | 1 |
Without a baseline, remove --baseline ty-baseline.json. Do not run --update-baseline in CI: recreating the record on every run would let new errors pass. If mypy already reports errors, deal with those separately.
Print ty --version right after installing so the log shows which version actually ran.
Speed was not measured. The official announcement says ty was the fastest on 16 of its 18 benchmark projects; treat that as the announcement's figure.