Skip to main content

Introspect Python type annotation, with ease.

Project description

header.png

Introspect Python type annotation, with ease.

GitHub Workflow Status PyPI Codecov

Modern Python libraries often use type annotations, this library is intended to help "de/serialize" Python type hints to something you can work with.

Sample Usage:

from typingref import TypeHinter
from typing import Union


class MyType:
    ...


def foo(p: Union[int, str, float]) -> MyType:
    ...


p_type = TypeHinter.from_annotation(foo.__annotations__['p'])

if p_type.is_union():
    for t in p_type.of_type:
        ...

assert Union[int, str, float] == p_type.as_annotation()

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

typingref-0.103.1.tar.gz (4.8 kB view hashes)

Uploaded Source

Built Distribution

typingref-0.103.1-py3-none-any.whl (4.2 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