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, and any arbitrary objects. It can be used together with static type checkers as an additional layer of type safety, to catch type violations that could only be detected at run time.
Two principal ways to do type checking are provided:
The check_type function:
like isinstance(), but supports arbitrary type annotations (within limits)
can be used as a cast() replacement, but with actual checking of the value
Code instrumentation:
entire modules, or individual functions (via @typechecked) are recompiled, with type checking code injected into them
automatically checks function arguments, return values and assignments to annotated local variables
for generator functions (regular and async), checks yield and send values
requires the original source code of the instrumented module(s) to be accessible
Two options are provided for code instrumentation:
the @typechecked function:
can be applied to functions individually
the import hook (typeguard.install_import_hook()):
automatically instruments targeted modules on import
no manual code changes required in the target modules
requires the import hook to be installed before the targeted modules are imported
may clash with other import hooks
See the documentation for further information.
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-4.4.1.tar.gz
.
File metadata
- Download URL: typeguard-4.4.1.tar.gz
- Upload date:
- Size: 75.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d22a89d00b453b47c49875f42b6601b961757541a2e1e0ef517b6e24213c21b |
|
MD5 | 842237266846dbb102b7239fcf4faeb6 |
|
BLAKE2b-256 | 62c3400917dd37d7b8c07e9723f3046818530423e1e759a56a22133362adab00 |
Provenance
The following attestation bundles were made for typeguard-4.4.1.tar.gz
:
Publisher:
publish.yml
on agronholm/typeguard
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
typeguard-4.4.1.tar.gz
- Subject digest:
0d22a89d00b453b47c49875f42b6601b961757541a2e1e0ef517b6e24213c21b
- Sigstore transparency entry: 146243982
- Sigstore integration time:
- Predicate type:
File details
Details for the file typeguard-4.4.1-py3-none-any.whl
.
File metadata
- Download URL: typeguard-4.4.1-py3-none-any.whl
- Upload date:
- Size: 35.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9324ec07a27ec67fc54a9c063020ca4c0ae6abad5e9f0f9804ca59aee68c6e21 |
|
MD5 | a7bb892198bda4246b3e2d31e085a0ea |
|
BLAKE2b-256 | f2539465dedf2d69fe26008e7732cf6e0a385e387c240869e7d54eed49782a3c |
Provenance
The following attestation bundles were made for typeguard-4.4.1-py3-none-any.whl
:
Publisher:
publish.yml
on agronholm/typeguard
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
typeguard-4.4.1-py3-none-any.whl
- Subject digest:
9324ec07a27ec67fc54a9c063020ca4c0ae6abad5e9f0f9804ca59aee68c6e21
- Sigstore transparency entry: 146243983
- Sigstore integration time:
- Predicate type: