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.1.tar.gz
(4.8 kB
view hashes)
Built Distribution
Close
Hashes for typingref-0.103.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59d2aa97a097dc3384bc575123682d9fc469e9b52c90baa3624bb4d3958ad9d9 |
|
MD5 | 1f504c281aad838e8b4d809f59b66325 |
|
BLAKE2b-256 | 7f8e6c90808ddc5bb9185191bf5e4de7e3a825efea3069f157b81e31c2386a1d |