This release has been yanked by its maintainers, and will be ignored by installers, except when explicitly specified.
Consider using release 2.2.1 instead.
Reason given by maintainers: Broken build
typing-validation is a library to perform runtime validation of Python objects using type hints.
Install
You can install the latest release from PyPI as follows:
pip install --upgrade typing-validation
Please note that v2.0.0 introduces breaking changes to the API, with support restricted to Python 3.14+.
Usage
The core functionality of this library is provided by the validate function:
>>> from typing_validation import validate
The validate function is invoked with a value and a type as its arguments and it returns nothing when the given value is valid for the given type:
>>> validate(12, int) True # no error raised => 12 is a valid int
If the value is invalid for the given type, the validate function raises a TypeError:
>>> validate(12, str) TypeError: Runtime validation error raised by validate(val, t), details below. For type <class 'str'>, invalid value: 12
For nested types (e.g. parametric collection/mapping types), the full chain of validation failures is shown by the type error:
>>> validate([0, 1, "hi"], list[int]) TypeError: Runtime validation error raised by validate(val, t), details below. For type list[...], invalid value at idx: 2 For type <class 'int'>, invalid value: 'hi'
The function is_instance is a variant of the validate function which returns False in case of validation failure, instead of raising TypeError:
>>> from typing_validation import is_instance >>> is_instance([0, 1, "hi"], list[int]) False
API
For the full API documentation, see https://typing-validation.readthedocs.io/
License
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file typing_validation-2.0.0.tar.gz.
File metadata
- Download URL: typing_validation-2.0.0.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bc39726da4b7f15ee156cda5378081d44ebccf1dc05f08be952715b37806b51
|
|
| MD5 |
73f466346d8d406746b01b82bbdfdc60
|
|
| BLAKE2b-256 |
ffacf1588bfa77a57ac1420de2f9903714dfa2b117712f2b5c73e5f2bf081107
|
File details
Details for the file typing_validation-2.0.0-py3-none-any.whl.
File metadata
- Download URL: typing_validation-2.0.0-py3-none-any.whl
- Upload date:
- Size: 18.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
113b7af32e225c98934b3e30d0b90e4fa2bf9a564f96c727cf34fe3934334a2f
|
|
| MD5 |
b0fb1e9f892b71bae2bfd1b5c9616151
|
|
| BLAKE2b-256 |
78fb8da3a601622f31b91745b716fea18f8dfccbab42c61c1ba6f156e6657950
|