Skip to main content

Strong - Dynamic type checker for function signatures

Strong embraces the builtin typing package by providing dynamic type checking for function signatures.

Install:

Simply use:

pip install strong

Documentation:

The documentation is hosted here.

Example:

Let's say you have a function taking two inputs, a and b, and returning one output. In Python, you can use type-hint in order to give clue about the type the parameters should have. Nonetheless, Python will not block inputs with the wrong type.

This package is here to provide tools to make the task of checking input parameters type easy.

>>> from strong.core.decorators import assert_correct_typing

>>> @assert_correct_typing
>>> def f(a: int, b: int) -> int:
>>>     return a + b

>>> x = f(1, 2)  # O.K.

>>> y = f(1, '2')  # K.O.
AssertionError: Function f defined in "<function_file>", line 3
    Argument `b` does not match typing: '2' is not an instance of <class 'int'>
>>> from strong.core.decorators import measure_overhead
>>> import numpy as np

>>> @measure_overhead(assert_correct_typing)
>>> def g(a: int, b: int) -> np.ndarray:
        return np.random.rand(a, b)

>>> g(100, 100)
1.0687804670719938  # Ratio between time taken with @assert_correct_typing and without

Metadata

Release files for strong 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for strong 0.2.2
File Size Uploaded
strong-0.2.2.tar.gz 8.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for strong 0.2.2
File Interpreter ABI Platform
strong-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 17.6 kB

Release files / strong-0.2.2.tar.gz

Download URL strong-0.2.2.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c73f513ec8b901b7389a7b040cc5ae7aadb45691a5260babfae48d3374fded50
BLAKE2b-256 checksum
How to use checksums
fc2d6baef7a8d7df2fc40fe0a7454855d95b3e08e17ebab285c05434d9fd1257
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.7.0 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.5

Release files / strong-0.2.2-py3-none-any.whl

Download URL strong-0.2.2-py3-none-any.whl
Size 9.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7391cba7a66daf6387984444a6a108580237a0bcd2f1327db0d781f456cfd0cc
BLAKE2b-256 checksum
How to use checksums
04c9675133ee290ad820c17c9ca0d41f3cce480bce9c57a95aefd742cea67905
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.7.0 requests/2.22.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page