Releases: nesalia-inc/python-typemap
Releases · nesalia-inc/python-typemap
Version 0.2.0
What's New in v0.2.0
This release adds comprehensive type utilities for type manipulation.
New Type Utilities
-
KeyOf[T] - Returns all member names as a tuple of Literal types
- Similar to TypeScript's
keyofoperator - Example:
KeyOf[User]returnstuple[Literal["name"], Literal["age"]]
- Similar to TypeScript's
-
*Template[Parts] - Template literal string builder
- Concatenates string literal types at runtime
- Example:
Template["api/v1/", Literal["users"]]returnsLiteral["api/v1/users"]
-
DeepPartial[T] - Make all fields recursively optional
- Applies optional transformation to all nested types
- Example:
DeepPartial[User]makes all nested fields optional
-
Partial[T] - Make all fields optional (non-recursive)
- Makes all top-level fields optional without recursion
- Example:
Partial[User]returnsname: str | None, age: int | None
-
Required[T] - Remove Optional from all fields
- Inverse operation of Partial
- Example:
Required[OptionalUser]removes| Nonefrom all fields
-
Pick[T, K] - Pick specific fields from a type
- Creates a new type with only the specified fields
- Example:
Pick[User, tuple["name", "email"]]
-
Omit[T, K] - Omit specific fields from a type
- Creates a new type excluding specified fields
- Example:
Omit[User, tuple["password"]]
Test Coverage
- 155 tests passing
- Full coverage for all new type utilities
Requirements
- Python 3.14+
- typing_extensions >= 4.0
Release 0.1.2
Include typemap_extensions in package build
Release 0.1.1
Fix: Export eval_typing from main package
Release 0.0.1
Initial release of typemap
- PEP 827 type manipulation library
- Includes eval_typing, Member, Attrs, Iter, Param, UpdateClass, NewProtocol, IsAssignable
- Requires Python 3.14+