Utilities for basedmypy
Project description
basedtyping
A collection of helpers and utilities to aid at dealing with types, both at static analysis and at runtime.
It's recommended to use basedmypy
when using basedtyping
,
as there are specialised adaptations made to basedmypy
to support some functionality of this package.
Features
ReifiedGeneric
A Generic
where the type parameters are available at runtime and usable in isinstance
and issubclass
checks.
For example:
class Foo(ReifiedGeneric[T]):
def hi(self):
print("Hi :)")
def foo(it: object):
# no error, as the class is reified and can be checked at runtime
if isinstance(it, Foo[int]):
print("wooow 😳")
assert_type
A type-time function used for testing types:
from typing import TYPE_CHECKING
if TYPE_CHECKING:
assert_type[int](foo) # type error if `foo` isn't an `int`
And many more!
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
basedtyping-0.0.3.tar.gz
(7.4 kB
view hashes)
Built Distribution
Close
Hashes for basedtyping-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 030f0ca886b6fbba5ed24a5a910b3681464ce2647aa1a0a63338f1e1c20ae7c4 |
|
MD5 | e3534c93f566bdca4fc8afbc12b6bd8c |
|
BLAKE2b-256 | 65fca2a0cf144402baae00fce4a6ca79f6c43ab65d96add93fa6a7d0612a2e1c |