Skip to main content

ty-migrate

Automated migration CLI for moving Python projects from mypy, pyright, and basedpyright to Astral's ty

PyPI version CI status License: MIT Python 3.11+ Zero Dependencies


While migrate-to-uv handles Poetry/Pipenv to uv and Ruff replaces Flake8/Black/isort, Astral's ty has had no automated configuration or inline-suppression migrator—forcing teams to manually rewrite mypy.ini, pyrightconfig.json, pyproject.toml, and hundreds of # type: ignore[...] / # pyright: ignore[...] comments.

ty-migrate automates the migration with zero third-party dependencies (Python 3.11+ stdlib only):

  • Multi-format config discovery & parsing:
    • mypy.ini, .mypy.ini, setup.cfg ([mypy] and [mypy-*]), pyproject.toml ([tool.mypy] + [[tool.mypy.overrides]])
    • pyrightconfig.json (JSONC-aware: strips //, /* */, and trailing commas safely), pyproject.toml ([tool.pyright], [tool.basedpyright], and executionEnvironments)
  • Idiomatic ty TOML generation:
    • Writes standalone ty.toml or safely inserts/updates [tool.ty.*] inside your existing pyproject.toml without disturbing other sections or comments.
    • Converts pure ignore_missing_imports = true module overrides into [tool.ty.analysis].allowed-unresolved-imports.
  • Tokenizer-safe inline suppression rewriting (--rewrite-ignores):
    • Uses Python's tokenize module so strings and docstrings containing # type: ignore are never touched.
    • Translates # type: ignore[code] and # pyright: ignore[reportXyz] into # ty: ignore[ty-rule] while preserving trailing comments.
  • Audit & CI modes:
    • --report prints translated settings, implicit/default-strict guidance, and unmapped items.
    • --diff / --dry-run previews every change safely.
    • --check exits with code 3 if any settings or inline ignore codes remain unmapped.
    • --verify runs ty check after migration when ty is installed.

Quick Start

# Run directly with uvx (zero install)
uvx ty-migrate --rewrite-ignores --report --verify

# Or preview changes safely first
uvx ty-migrate --dir . --rewrite-ignores --dry-run --diff --report

# Or install globally / with pip
pip install ty-migrate

Example Output

$ ty-migrate --rewrite-ignores --dry-run --diff --report
--- a/ty.toml
+++ b/ty.toml
@@ -0,0 +1,14 @@
+[environment]
+python-version = "3.12"
+
+[analysis]
+allowed-unresolved-imports = ["vendor_missing.*"]
+
+[rules]
+import-not-found = "ignore"
+redundant-cast = "warn"
+missing-attribute = "ignore"
+
+[[overrides]]
+include = ["tests/**"]
+rules = { invalid-argument-type = "ignore" }

--- a/app.py
+++ b/app.py
@@ -1 +1 @@
-x: int = "bad"  # type: ignore[assignment]  # legacy fixture
+x: int = "bad"  # ty: ignore[invalid-assignment]  # legacy fixture
=== ty-migrate Audit Report ===
Sources: mypy (mypy.ini)
Summary: 6 translated, 1 guidance/implicit, 0 unmapped

[Translated]
  - mypy.ini:python_version -> environment.python-version (3.12)
  - mypy.ini:ignore_missing_imports=True -> rules.import-not-found=ignore
  - mypy.ini:warn_redundant_casts=True -> rules.redundant-cast=warn
  - mypy.ini:error_code:attr-defined -> rules.missing-attribute=ignore
  - mypy.ini:[mypy-vendor_missing.*] -> analysis.allowed-unresolved-imports (vendor_missing.*)
  - mypy.ini:[mypy-tests.*]:error_code:arg-type -> rules.invalid-argument-type=ignore

[Guidance / Implicit in ty]
  - mypy.ini:strict=True -> (implicit / guidance) (ty has no single `strict` flag (its defaults are already strict); enable extra strict rules like `possibly-missing-attribute` or `unsound-return` in `[tool.ty.rules]` if desired.)

[Inline Ignore Comments]
  - Rewritten: 1
  - Unchanged: 0

Metadata

Release files for ty-migrate 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ty-migrate 0.1.0
File Size Uploaded Provenance Actions
ty_migrate-0.1.0.tar.gz 27.3 kB With provenance Details for ty_migrate-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ty-migrate 0.1.0
File Interpreter ABI Platform Actions
ty_migrate-0.1.0-py3-none-any.whl Python 3 none any Details for ty_migrate-0.1.0-py3-none-any.whl

Total release size: 52.5 kB

Release files / ty_migrate-0.1.0.tar.gz

Download URL ty_migrate-0.1.0.tar.gz
Size 27.3 kB
Tags Source
SHA-256 checksum
How to use checksums
24910e8f97396a99d6204d169a4e7ce1197a73f8be4d1c990cce926c9bcdac4e
BLAKE2b-256 checksum
How to use checksums
9c84d3708285b3de701b65ed92b77a6c7367a699f4e360bdcc7676526f4ae107
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Release files / ty_migrate-0.1.0-py3-none-any.whl

Download URL ty_migrate-0.1.0-py3-none-any.whl
Size 25.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d449bcbb84388d4e939a7051ae9afd3febcda26761c172a5038eba1f638c9cd4
BLAKE2b-256 checksum
How to use checksums
1997941a1c7bf428d1ce0e140809661d4eadd32ecb76cbebdb23278f5d355228
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

Security for ty-migrate 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for ty_migrate-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page