Skip to content
Typhon language logo

Python, checked before it runs.

A typed language for Python developers. Make optional values and errors explicit, then compile to readable Python.

The 30-second pitch

Write .ty, check it with tyc, and deploy readable .py.

Write .ty source with explicit types, bindings and error handling. tyc checks it and compiles it to readable Python for CPython 3.13 or newer. Use your Python dependencies through typed signatures and stubs. You do not install the compiler or a separate Typhon runtime package in production; features such as Result generate small Python helpers inside the build output.

type LoadError = NotFound | Timeout
class NotFound:
path: str
class Timeout:
after_ms: int
def load(path: str) -> Result[str, LoadError]:
try:
with open(path) as f:
return Ok(f.read())
except FileNotFoundError:
return Err(NotFound(path=path))
def main() -> None:
match load("config.toml"):
case Ok(body):
print(body)
case Err(NotFound(path)):
print(f"missing: {path}")
case Err(Timeout(after_ms)):
print(f"timed out after {after_ms}ms")

The match on LoadError is statically exhaustive. Add a third variant to the union, and Typhon identifies matches that need to handle it.

What you get

Non-nullable by default

Plain T cannot hold None. Use T? when you mean optional. Flow narrowing on is None, is not None, isinstance, guard, and early returns.

No implicit Any

Untyped values are a hard error outside unsafe: blocks. The strictness is stronger than TypeScript’s noImplicitAny.

Errors as values

Result[T, E], Ok, Err, and the ? operator make failure visible in signatures — without giving up Python’s exception bridge.

Sealed unions + exhaustive match

type Shape = Circle | Rectangle | Triangle. Add a variant; every match lights up red. Refactor with confidence.

Explicit async, smarter concurrency

gather: lowers to asyncio.TaskGroup (the safe default). go f(x) spawns fire-and-forget through a strong-ref registry. No GC’d tasks.

Build-time configuration

comptime let PORT: int = int(env("PORT", "8080")) inlines at build time. Missing required env vars fail the build, not production.

Readable Python output

Emits idiomatic Python you can read, debug, and ship. The handful of helpers (Result, lazy, task registry) is generated locally as typhon_runtime/. No PyPI install.

One binary, full pipeline

tyc includes the compiler, formatter, language server, REPL, in-process interpreter, migrator, debugger launcher and package-manager commands.

Start here

Status

The current release is v1.0.0-beta.7, which fixes a generic-annotation false positive on dependency classes, orders the generated __all__ for ruff, and documents committing the build manifest, on top of v1.0.0-beta.6 (checks on what a third-party function returns, including @deprecated APIs and properties) and v1.0.0-beta.5’s third-party checking and build fixes.

  • Build and deploy on CPython. tyc build writes Python and any required generated helpers. Deploy it with your application’s Python dependencies; the compiler is not needed in production.
  • Review the beta compatibility policy. The core forms listed in the policy keep their syntax and meaning during beta. New checks and deliberate exceptions follow that policy; review the changelog before upgrading.
  • Still deferred: embedded in-process ty (the subprocess [checker] external = "ty" path ships), typeshed-backed checking for pure-extension libraries, and the function-level HKT tail.

For the full breakdown see Project Status; for the release-by-release history see the changelog.

Typhon supports CPython 3.13, 3.14 and 3.15 targets, including their free-threaded builds. The default is 3.13. Configure the Python target to enable newer syntax and builtins; the compiler rejects features newer than the selected target.