Cleaner and forwards compatible way to use typing features
Project description
Overview
Tippo provides a cleaner and forwards compatible way to use features from the typing and typing_extension modules on python 3.7+.
Example
Instead of using an ugly try block for forwards compatibility…
>>> try:
... from typing import Annotated
... except ImportError:
... from typing_extensions import Annotated
...
>>> try:
... from typing import final
... except ImportError:
... from typing_extensions import final
...
…just import directly from tippo!
>>> from tippo import Annotated, final
Generic Weak Structures
Tippo also implements generic versions of weak data structures that work with older python versions’ type annotations (3.7) without the need to defer their evaluation:
>>> from tippo import Any, ReferenceType, WeakSet, WeakKeyDictionary, WeakValueDictionary
>>> class X:
... pass
>>> weak_ref: ReferenceType[X]
>>> weak_set: WeakSet[X]
>>> weak_key_dict: WeakKeyDictionary[X, Any]
>>> weak_value_dict: WeakValueDictionary[Any, X]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tippo-0.1.0.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for tippo-0.1.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f82556884808ea31a12648ff25736f4be67f35cdf9a2a06e618d3c79299e68d3 |
|
MD5 | 56e29857c2ccfaab5b8aa7b538391011 |
|
BLAKE2b-256 | fb0da5c8146bd98149ca7a22de6e7274f330d5de77857e6c7f0ccb71da7e74c0 |