tytr
Type transformations for Python.
Create types from class definitions.
Create tests to keep those types up to date.
Type creation
# foo.py
class Foo:
a: int
b: floatA TypedDict based on Foo:
$ tytr gen typeddict foo.py::Foo --name FooDict# Generated by tytr gen typeddict
from __future__ import annotations
from typing_extensions import TypedDict
class FooDict(TypedDict):
a: int
b: floatA protocol for a getter for Foo:
$ tytr gen getter foo.py::Foo --name GetFoo# Generated by tytr gen getter
from __future__ import annotations
from typing import Literal, Protocol, overload
class GetFoo(Protocol):
@overload
def __call__(self, key: Literal["a"]) -> int: ...
@overload
def __call__(self, key: Literal["b"]) -> float: ...... and many more
On this page
Languages
Python100.0%
Contributors
MIT License
Created December 24, 2025
Updated January 13, 2026