Skip to main content

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


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)

Uploaded Source

Built Distribution

basedtyping-0.0.3-py3-none-any.whl (8.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page