Skip to main content

Python typing compatibility library

Project description

typing-compat

Python typing compatibility library


In Python >=3.8 the typing.get_origin and typing.get_args functions are provided. This library aims to bring the identical behaviour of these functions to other versions of Python.

Getting started

pip install typing-compat

Usage

>>> from typing import List, Tuple, TypeVar
>>> from typing_compat import get_args, get_origin
>>> T = TypeVar('T')

>>> tp = List[Tuple[T, T]][int]

>>> get_args(tp)
(typing.Tuple[int, int],)

>>> get_origin(tp)
<class 'list'>

License

This library is licensed under either of

at your option.

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

typing-compat-0.1.0.tar.gz (3.5 kB view hashes)

Uploaded Source

Built Distribution

typing_compat-0.1.0-py2.py3-none-any.whl (7.9 kB view hashes)

Uploaded Python 2 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