Run-time type checker for Python
Project description
This library provides run-time type checking for functions defined with PEP 484 argument (and return) type annotations.
Three principal ways to do type checking are provided, each with its pros and cons:
the check_argument_types() and check_return_type() functions:
debugger friendly (except when running with the pydev debugger with the C extension installed)
does not work reliably with dynamically defined type hints (e.g. in nested functions)
the @typechecked decorator:
automatically type checks yields and sends of returned generators (regular and async)
adds an extra frame to the call stack for every call to a decorated function
the stack profiler hook (with TypeChecker('packagename'):) (deprecated):
emits warnings instead of raising TypeError
requires very few modifications to the code
multiple TypeCheckers can be stacked/nested
does not work reliably with dynamically defined type hints (e.g. in nested functions)
may cause problems with badly behaving debuggers or profilers
cannot distinguish between an exception being raised and a None being returned
the import hook (typeguard.importhook.install_import_hook()):
automatically annotates classes and functions with @typechecked on import
no code changes required in target modules
requires imports of modules you need to check to be deferred until after the import hook has been installed
may clash with other import hooks
See the documentation for further instructions.
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
Built Distribution
File details
Details for the file typeguard-2.6.0.tar.gz
.
File metadata
- Download URL: typeguard-2.6.0.tar.gz
- Upload date:
- Size: 30.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d6e2a09f8d257bcda49e6178fc08c518fb530f259a5443f3bcf422713dca6bf |
|
MD5 | 39c8225ad959873d34c0f4ee37560e1a |
|
BLAKE2b-256 | b56382e556664677d068150d62af4cf67bc7cf3020300ef889645b4b0aad48dd |
File details
Details for the file typeguard-2.6.0-py3-none-any.whl
.
File metadata
- Download URL: typeguard-2.6.0-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d7877004f4ed39e2381612bbb7a56ec4386da3fa405a0ada10e8baaefbcbc56 |
|
MD5 | ec5009c4b26750607711bfd839b4a4a8 |
|
BLAKE2b-256 | 8e7bf40a24d790227927f3c95b4cb5981d417b88cdc806575ddcdf985776e403 |