Skip to main content

Strict type runtime checks for arguments and return types.

Project description

Strict hint provides a way to do runtime type checks based based on type hint annotations introduced by PEP-484.

Usage is quite simple, just add type annotations to a function or method and decorate it with @strict:

from strict_hint import strict

def add(a: int: b: int) -> int:
    return a+b

If non int will be passed, a TypeError will be raised. Same will happen if function would return different type than expected.

Type checks support (for arguments and returned values):
  • all primitive type hints: int, float, list, tuple, set, dict, etc.,
  • standard interpreter types eg.: FunctionType and other,
  • tuples of types, eg: (int, float) will allow for both types to be accepted,
  • default values, also of different type than annotation: eg. a: int = None
  • used defined classes and class inheritance

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for strict-hint, version 0.3.0
Filename, size File type Python version Upload date Hashes
Filename, size strict-hint-0.3.0.tar.gz (2.8 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page