Skip to main content

TypePython

TypePython

Write richer types in .tpy. Ship plain .py + .pyi.


TypePython is a typed dialect of Python that compiles to standard .py + .pyi. It brings TypeScript-class ergonomics — sealed classes, exhaustive match, strict null checks, unknown, interface, data class — to a language whose output runs anywhere CPython runs.

No custom runtime. No per-checker plugin. No vendor lock-in.

Status: Core v1 Beta (v0.4.0). Core syntax, config, init/check/build/ clean/verify, diagnostic code identity, and emitted .py/.pyi compatibility are the stable Beta surfaces. LSP UX, adapter manifests, runtime validators, and migration heuristics remain prototype/experimental. Bug reports and contributions are very welcome.

Install

pip install type-python
typepython init --dir hello && cd hello
typepython check --project .
typepython build --project .

You now have .typepython/build/ with .py + .pyi + py.typed ready for any Python interpreter, IDE, or downstream type checker.

  • Wheels are prebuilt for Windows AMD64, macOS x86_64, macOS arm64, and Linux x86_64. Other platforms fall back to source and need Rust + cargo.
  • Python: the package bridge supports 3.9+; generated projects target Python 3.10 through 3.14.

See it in 15 lines

# src/app/expr.tpy

sealed class Expr:
    pass

class Num(Expr):  value: int
class Add(Expr):  left: Expr; right: Expr
class Neg(Expr):  operand: Expr

def evaluate(expr: Expr) -> int:
    match expr:
        case Num(value=v):           return v
        case Add(left=l, right=r):   return evaluate(l) + evaluate(r)
        case Neg(operand=o):         return -evaluate(o)
    # No default branch needed — the compiler proves the match is exhaustive.
    # Add a fourth subclass and TypePython tells you exactly where to update.

typepython build lowers that to ordinary Python and writes a matching .pyi that any modern type checker can consume — no TypePython runtime required.

What you write vs. what ships

You write (.tpy) TypePython emits (.py / .pyi)
interface Drawable: class Drawable(Protocol):
data class User: @dataclass class User:
sealed class Expr: ordinary class + tpy:sealed marker
overload def parse(...) @overload def parse(...)
typealias Pair[T] = tuple[T, T] T = TypeVar("T") + Pair: TypeAlias = tuple[T, T]
def first[T](xs: list[T]) -> T: inline generic on 3.13+, TypeVar-based on 3.10 – 3.12
unsafe: eval(expr) valid Python, marker erased — runtime behavior preserved
unknown (must narrow before use) object in .pyi
Partial[Config] / Pick[Config, …] expanded TypedDict shapes (PEP 655 / 705)

Why not just mypy / pyright / PEP 695?

Capability mypy strict pyright strict PEP 695 .py TypePython .tpy
sealed class + compiler-proved exhaustiveness — — — ✅
unknown — safe dynamic boundary, must narrow — — — ✅
unsafe: audit fence for eval / exec / setattr — — — ✅
First-class interface / data class / typealias via via via keyword
Inline generics def f[T] on any target ≥ 3.10 3.12+ 3.12+ 3.12+ ✅
TypedDict transforms (Partial, Pick, Readonly…) — — — ✅
Output consumed by mypy / pyright / ty unmodified N/A N/A ✅ ✅

TypePython doesn't replace those checkers. It sits one step earlier: you author in .tpy, the compiler emits standard typed Python that those tools then consume normally.

What you also get

  • Rust-native, incremental compiler — public-API fingerprints skip downstream rechecks when only a body changes.
  • Full toolchain — init, check, build, watch, clean, verify, compat, api-diff, type-health, migrate, lsp.
  • LSP server — hover, go to definition, references, rename, completions, signature help, real-time diagnostics, and code-action quick fixes. Bring your own LSP-capable editor (VS Code, Neovim, Helix, Sublime, Emacs).
  • Standard, portable output — emitted .py + .pyi work with mypy, pyright, and ty out of the box. PEP 561 py.typed is written automatically.
  • Mixed projects — .tpy, .py, and .pyi live in the same source tree. .py is pass-through; .pyi is stub-authoritative.

For library authors

Five commands aimed at people who publish typed Python:

typepython build       --project .
typepython verify      --project . --checker-preset all
typepython compat      --project . --profile library-portable
typepython api-diff    dist/previous.whl .typepython/build
typepython type-health --project . --fail-under 85

These catch missing/stale py.typed, wheel ↔ build-tree drift, multi-checker portability gaps, public-API drift between releases, and runtime-annotation hazards for frameworks that introspect annotations.

Documentation

Links

Metadata

Release files for type-python 0.4.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 type-python 0.4.0
File Size Uploaded
type_python-0.4.0.tar.gz 1.1 MB Details

Built distributions (wheels)

Table of built distributions (wheels) for type-python 0.4.0
File
type_python-0.4.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
type_python-0.4.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
type_python-0.4.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
type_python-0.4.0-py3-none-macosx_10_13_x86_64.whl Python 3 none macOS 10.13+ x86-64 Details

Total release size: 21.8 MB

Release files / type_python-0.4.0.tar.gz

Download URL type_python-0.4.0.tar.gz
Size 1.1 MB
Tags Source
SHA-256 checksum
How to use checksums
8ef4885aa28a746bcc24f7549133c2c37d42151e6c4cc78666815b1363f32cb6
BLAKE2b-256 checksum
How to use checksums
9560931a3e8462687043ad266c001c4fb6bcc71a947e7af004481120e64b3335
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 5, 2026.

Transparency log

Release files / type_python-0.4.0-py3-none-win_amd64.whl

Download URL type_python-0.4.0-py3-none-win_amd64.whl
Size 5.3 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
dfecc8682965a5055be29f1d70b54f816524345ae93fb382809d8c9a24ed0c6c
BLAKE2b-256 checksum
How to use checksums
74305e5598a71be37dec5c1488ad015839e09302fe845dc6b8d4f00d809fdde9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 5, 2026.

Transparency log

Release files / type_python-0.4.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL type_python-0.4.0-py3-none-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 5.4 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
6da0e1cdc88755151bbb3de846e85c558e1c9ffcdd127f54a9db2f774c67899c
BLAKE2b-256 checksum
How to use checksums
48b462dc7e12fb77c24f4f56fef5b15a0d286c7d5f1a8b8c7cca7464c06a5263
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 5, 2026.

Transparency log

Release files / type_python-0.4.0-py3-none-macosx_11_0_arm64.whl

Download URL type_python-0.4.0-py3-none-macosx_11_0_arm64.whl
Size 4.8 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
31143584c9111066e3bf540eb50e9f1bb522e6c3c1022c3fd75b04e813fae895
BLAKE2b-256 checksum
How to use checksums
b822784a407b6148c695365f07ef91952b2da8259884416a5967b66864dd2dc8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 5, 2026.

Transparency log

Release files / type_python-0.4.0-py3-none-macosx_10_13_x86_64.whl

Download URL type_python-0.4.0-py3-none-macosx_10_13_x86_64.whl
Size 5.2 MB
Tags Python 3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
b0a2b50a781c79408aef8929ecd7cf0953f67bbbe042122b41cebdb08ec90d47
BLAKE2b-256 checksum
How to use checksums
55cdacbc82fd5c2c7f59fc92a5752eead2991d2db98c0286f10a85aa41aaabe5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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 May 5, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

5 release files

0.3.1

5 release files

0.3.0

5 release files

0.2.0

5 release files

0.1.1

5 release files

0.1.0

5 release files

0.0.8

5 release files

0.0.7

5 release files

0.0.4

1 release file

0.0.1

2 release files

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