Skip to content

vercel/python-typemap

Repository files navigation

Type Manipulation in Python

This is the development repository for PEP 827 – Type Manipulation, which proposes TypeScript-inspired type-level introspection and construction facilities for the Python type system.

This repository contains an implementation of the proposed additions to typing (typemap/typing.py), exported as the module typemap_extensions.

It also contains a prototype runtime evaluator (typemap/type_eval).

Discussion of the PEP is at the PEP 827 discussion thread.

A prototype typechecker implementation lives at https://github.com/msullivan/mypy-typemap and is a test dependency of this repo.

There is an example repo with a straightforward skeleton for playing around with the proposal.

Development

  1. Clone the repo
  2. $ cd typemap
  3. $ uv sync
  4. $ uv run pytest

Running the typechecker

The prototype mypy can be run from this repo with uv run mypy. Stubs are set up so that importing typemap_extensions will do the right thing.

uv run pytest tests/test_mypy_proto.py will run the mypy prototype against a supported subset of test files.

You can also run the prototype mypy directly on a file with uv run mypy <file>

About

Type Manipulation PEP

Resources

License

Security policy

Stars

Watchers

Forks

Contributors