A programmable type system for Python

Python’s runtime is famously flexible. Classes, methods, and even entire APIs can be generated programmatically, decorators can modify behavior at will, and metaprogramming is a first-class concept. Static typing, however, has struggled to keep pace with that dynamism without resorting to typechecker plugins or repetitive boilerplate.

That gap is the target of a year-long research effort that has culminated in PEP 827: Type Manipulation. The proposal introduces a set of standard, type-level building blocks for both introspecting existing types and constructing new ones. The goal is to give Python’s type system a programmable core — closer in spirit to TypeScript’s utility types, but adapted to Python’s runtime semantics rather than trying to mimic TypeScript’s dedicated typing syntax.

The potential is significant enough that FastAPI creator Sebastián Ramírez weighed in on the Python Discourse thread about the proposal:

A familiar example: Pick and Omit

One concrete illustration of the idea comes from TypeScript’s well-known utility types. Here is Pick implemented side by side in TypeScript and with the proposed Python APIs:

The comparison highlights a core difference: TypeScript has dedicated typing syntax that is concise but feels removed from the rest of the language. Python leans on its standard imperative syntax, exposing the type-level logic through APIs that read like ordinary code.

Implementing Omit follows suit:

Notably, Python’s Omit is nearly identical to its Pick, differing only by an inverted condition. TypeScript requires a more substantial rewrite, composing the two utilities differently to achieve the same result.

That contrast underscores the core philosophy of PEP 827: not making Python look like TypeScript, but giving Python typing a programmable foundation that aligns with the language’s own model. Because the type-level manipulation remains introspectable at runtime, frameworks like Pydantic stand to benefit as well as type checkers.

Next steps and the role of tooling

PEPs go through debate, revision, and sometimes rejection on the path to acceptance. The authors of this research build across both TypeScript and Python, and they view the investment in this proposal as part of keeping both ecosystems healthy.

There is a fair question tucked into the announcement: in an era where AI agents write an increasing share of source code, do language syntax, tooling, and type system capabilities still warrant close attention? The case laid out is that they matter more than ever. More expressive type systems enable type checkers to do thorough analysis and frameworks to ship richer behavior. The result is code that is more succinct and easier to review — less boilerplate to maintain, both now and as tooling evolves.