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] == TypeHinter.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.100.0.tar.gz
(4.6 kB
view hashes)
Built Distribution
Close
Hashes for typingref-0.100.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c3eaf8b03fee2c2b6f3035a018cec197bf81ed7745bc50079f96b861ea78e9c |
|
MD5 | 24b5299e7669eea192fc7d9157e00fdf |
|
BLAKE2b-256 | ac33f100c034861be076e4e4e184697c9d191ac0085b8244314a2ea1982db368 |