Skip to main content

No project description provided

Project description

typeapi

Typeapi provides a sane and stable API to introspect Python type hints.

Installation

$ pip install typeapi

Quickstart

import typing
from typeapi import parse_type_hint

print(parse_type_hint(typing.Any))                  # Type(object)
print(parse_type_hint(typing.List))                 # Type(list)
print(parse_type_hint(typing.Mapping[str, int]))    # Type(collections.abc.Mapping, (Type(str), Type(int)))
print(parse_type_hint(typing.Union[str, int]))      # Union(int, str)
print(parse_type_hint(str | int))                   # Union(int, str)
print(parse_type_hint(str | int | None))            # Optional(Union[int, str])
print(parse_type_hint(typing.Annotated[int, 42]))   # Annotated(int, 42)
print(parse_type_hint(typing.Annotated[int, 42]))   # Annotated(int, 42)
print(parse_type_hint('str', __name__))             # Type(str)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

typeapi-0.1.0a1.tar.gz (7.5 kB view hashes)

Uploaded Source

Built Distribution

typeapi-0.1.0a1-py3-none-any.whl (8.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page