Skip to main content

Run-time type checker for Python

Project description

Build Status Code Coverage https://readthedocs.org/projects/typeguard/badge/?version=latest

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:

  1. 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)

  2. 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

  3. the stack profiler hook (with TypeChecker('packagename'):):

    • 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

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

typeguard-2.5.1.tar.gz (25.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

typeguard-2.5.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file typeguard-2.5.1.tar.gz.

File metadata

  • Download URL: typeguard-2.5.1.tar.gz
  • Upload date:
  • Size: 25.8 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.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

File hashes

Hashes for typeguard-2.5.1.tar.gz
Algorithm Hash digest
SHA256 5269435c8c98f4c4861dd69f3de755aaab5e163991b7ce1e0eff7ae6472957dd
MD5 31e4d69f88c6a9c57ab09f7880d47c81
BLAKE2b-256 4b2d2f7a3ea8bfc683d26b3a1f80725a1084296cfc008ea77bd9eea48051616e

See more details on using hashes here.

File details

Details for the file typeguard-2.5.1-py3-none-any.whl.

File metadata

  • Download URL: typeguard-2.5.1-py3-none-any.whl
  • Upload date:
  • Size: 11.8 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.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.7

File hashes

Hashes for typeguard-2.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ca77fe94688dd003c37fc1d04a1c1d824ea3b873ef056766ad8590ce40d506e3
MD5 b94c98bc83406a39d8de668705e91717
BLAKE2b-256 cd0bf1da508c75cefe70aa03d984f1a9cf0497ca016f8c8d942379787dbeb6cb

See more details on using hashes here.

Supported by

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