Project: typing-compat

Python typing compatibility library

Project Details

Latest version
0.1.0
Home Page
https://github.com/rossmacarthur/typing-compat
PyPI Page
https://pypi.org/project/typing-compat/

Project Popularity

PageRank
0.002313775343428938
Number of downloads
167499

typing-compat

Python typing compatibility library

Build status Code style: black

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

  • Apache License, Version 2.0 (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
  • MIT License (LICENSE-MIT or https://opensource.org/licenses/MIT)

at your option.