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.102.0.tar.gz
(4.7 kB
view hashes)
Built Distribution
Close
Hashes for typingref-0.102.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 364cc4255cc0e1e036f78658154462f8679ab660b0db6cf716a7967df07ddffe |
|
MD5 | 4ff1188469d27464b6e0a283c84f087f |
|
BLAKE2b-256 | 7882dc6d9fdabde01911dedc130bd907020d232024ca5649b32616cd88c72a73 |