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_annotations(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.101.0.tar.gz
(4.6 kB
view hashes)
Built Distribution
Close
Hashes for typingref-0.101.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b43bc74772a49d673defecddc119422882e3dd54827074a6781c8abb1649179 |
|
MD5 | e099952f93b6c2fe275116f186eef011 |
|
BLAKE2b-256 | d8f2ff71d1c06fd6dae1283c3aaaeacbaec90e6c852b9863db8ae1b39d2709d6 |