Introduction
PEP 827 type manipulation library for Python 3.14+
typemap is a runtime type evaluation library for Python 3.14+ that implements the type manipulation operators from PEP 827.
Installation
pip install typemapQuick Example
from typemap import eval_typing
import typemap_extensions as tm
class User:
name: str
age: int
email: str
# Get all field names at runtime!
keys = eval_typing(tm.KeyOf[User])
# Returns: tuple[Literal["name"], Literal["age"], Literal["email"]]What Can You Do?
- Introspect types - Get field names, types, annotations
- Transform types - Pick, omit, make optional, etc.
- Build dynamically - Create protocols, classes at runtime
- Validate - Check type compatibility at runtime
Getting Started
What is typemap?
Understand the core concept
Why Runtime Types?
Learn why this is useful
Installation
How to install
Tutorial
Step-by-step guide
Type Utilities
Pick
Select specific fields
Omit
Exclude specific fields
Partial
Make fields optional
KeyOf
Get all field names
Requirements
- Python 3.14+
- typing_extensions >= 4.0
Credits
This project is 100% inspired by vercel/python-typemap. All credit goes to them - they are the real creators of this implementation.
We hope with all our hearts that PEP 827 will be accepted!
Note: This library is a prototype. PEP 827 is not yet finalized!