A runtime type-checking module for Python
Project description
A runtime type-checking module for Python supporting both parameter-type checking and return-type checking.
The main workhorses of this module, the functions typecheck_args and typecheck_return, are used as function/method decorators (see Examples section).
Typecheck supports arbitrarily complex data-structures, able to deal with nested arrangements of tuples, lists and dictionaries.
Two utility classes, And() and Or(), are provided to assist in building more complex signatures by creating boolean expressions based on classes and/or types. A similar class, Any(), can be used to indicate that you don’t care about the type of the object.
Note that typechecking can be {en,dis}abled at runtime by toggling the typecheck.enable_checking global boolean; a value of True (the default) causes all typechecks (both for parameters and return values) to be run, while False disables them.
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.