typetoolbox
typetoolbox provides runtime utilities for inspecting Python generics and resolving TypeVar bindings.
Installation
uv add typetoolbox
Core APIs
GenericTypeMap: mapTypeVarnames to concrete runtime types for a generic class/alias.get_generic_mapping(obj_or_type): build aGenericTypeMapfrom a class, alias, or object instance.resolve_typevars(tp, mapping_source, strict=False): recursively resolveTypeVars in nested type expressions.find_specializations(base_generic, where=None): find subclasses that fully close a base generic.inspect_specializations(base_generic, include_generic=False, where=None): inspect subclasses with rich mapping metadata.find_specializations_by_args(base_generic, args): return exact-arg specializations.build_specialization_index(base_generic): map resolved arg tuples to implementations.try_to_map_generic_args_to_specialization(generic_type, specialization_type): map generic args onto a concrete specialization.
Example
from typing import Generic, TypeVar
from typetoolbox import GenericTypeMap, find_specializations, resolve_typevars
X = TypeVar("X")
Y = TypeVar("Y")
class Pair(Generic[X, Y]):
pass
class IntStrPair(Pair[int, str]):
pass
mapping = GenericTypeMap(IntStrPair)
assert resolve_typevars(dict[X, list[Y]], mapping) == dict[int, list[str]]
assert find_specializations(Pair) == [IntStrPair]
Metadata
Release files for typetoolbox 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| typetoolbox-0.4.0.tar.gz | 61.7 kB | Without provenance | Details for typetoolbox-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| typetoolbox-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for typetoolbox-0.4.0-py3-none-any.whl |
Total release size: 73.1 kB
Release files / typetoolbox-0.4.0.tar.gz
| Download URL | typetoolbox-0.4.0.tar.gz |
|---|---|
| Size | 61.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d72b2b24389e2d23ab8d1ba4132285493fc3884afd006950ba525fe9d3357c4
|
|
BLAKE2b-256 checksum How to use checksums |
ff259b1fbd56714cad55eac2ad541aa7e4eca621010f242defc1596b866d8b7e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / typetoolbox-0.4.0-py3-none-any.whl
| Download URL | typetoolbox-0.4.0-py3-none-any.whl |
|---|---|
| Size | 11.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5435b992632535f519b55b9df6498cb1fd1e1b9e71b4120615c77c81cc3901e9
|
|
BLAKE2b-256 checksum How to use checksums |
3dc329efcdf05fcd70472fcee5b3c002834929ce2f5db1f6e5072dcbcd3cf650
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for typetoolbox 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.