Skip to content

nesalia-inc/python-typemap

 
 

python-typemap

PyPI Version Python Version Test Status License: MIT Ruff Code Quality

PEP 827 type manipulation library for Python 3.14+

Installation

pip install typemap

Overview

This repository contains the typemap package, which provides utilities for working with PEP 827 type manipulation operators.

Features

Operator TypeScript Description
eval_typing - Evaluate type expressions at runtime
Member MemberType Access type members by name
Attrs - Get class attributes
Iter - Iterate over type contents
Param Parameter Define callable parameters
UpdateClass - Generate class modifications
NewProtocol interface Create protocols dynamically
IsAssignable extends Check type assignability
KeyOf keyof Get all member names as tuple of Literals
Template template literals Build template literal strings
DeepPartial DeepPartial Make all fields recursively optional
Partial Partial Make all fields optional (non-recursive)
Required Required Remove Optional from all fields
Pick Pick Pick specific fields from a type
Omit Omit Omit specific fields from a type

Documentation

See packages/typemap/README.md for detailed usage.

Requirements

  • Python 3.14+
  • typing_extensions >= 4.0

About This Project

This project is 100% inspired by vercel/python-typemap. All the credit and work goes to them - they are the real creators of this implementation.

This repository is simply a packaged version of the original work by Vercel. The goal is to make this PEP 827 implementation available on PyPI for easier installation and distribution.

All the intellectual work, research, and implementation was done by the Vercel team. They are the ones who wrote the PEP draft, created the prototype, and demonstrated what's possible with type manipulation in Python.

We hope with all our hearts that PEP 827 will be accepted. This PEP represents a major step forward for Python's type system and would enable powerful type-level computations that are currently only possible in TypeScript.

If you appreciate this work, please star and support the original vercel/python-typemap repository!

About

PEP 827 type manipulation library for Python 3.14+. Runtime type evaluation and transformation operators inspired by TypeScript.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Python 89.1%
  • MDX 5.5%
  • TypeScript 4.4%
  • Other 1.0%