Introspect Python type annotation, with ease.
Project description
Introspect Python type annotation, with ease.
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.0.tar.gz
(4.8 kB
view hashes)
Built Distribution
Close
Hashes for typingref-0.103.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 138ea7c5e73f70942529a0875ad544cf076deca5db08ea3b1b1506485cac700a |
|
MD5 | f611274418e0c5c6949afb5100686551 |
|
BLAKE2b-256 | 32a73cf5c421c8fa37725288d56011678255b3b8e5f24a1c7e8cd5441b8f9c29 |