pvv
Minimal Python decorator to enforce type validation from type hints
Installation
This library has been created to have zero dependencies, and work with native Python. Use your favorite package manager to install pvv from PyPI.
pip install pvv
Usage
There are two ways to use the validate decorator from pvv:
Validate all parameters
Just use the decorator. A TypeError will be raised if the function is called with parameters of incorrect type.
from pvv import validate
@validate
def function(a: str, b: int, c):
pass
>>> function("a", 3, 2)
>>> function(c=2, a="a", b=2)
>>> function(3, "a", 2)
TypeError: Incorrect type of function arguments: 'a' must be of type 'str', 'b' must be of type 'int'
Validate some parameters
from pvv import validate
@validate('a', 'c')
def function(a: str, b: int, c: bool | None):
pass
>>> function("a", 3, True)
>>> function(3, "b", 0)
TypeError: Incorrect type of function arguments: 'a' must be of type 'str', 'c' must be of type 'bool | None'
An important note
The parameters of the validate decorator must all be of type str, otherwise a ValidatorError will be raised:
>>> @validate('a', 1)
... def func(*args, **kwargs):
... pass
pvv.exceptions.ValidatorError: All arguments of decorator must be of type 'str'
Metadata
Release files for pvv 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pvv-1.0.0.tar.gz | 3.9 kB | Without provenance | Details for pvv-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pvv-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for pvv-1.0.0-py3-none-any.whl |
Total release size: 8.4 kB
Release files / pvv-1.0.0.tar.gz
| Download URL | pvv-1.0.0.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f19c8eba7943fb170eb217ed143514b86a444f3a000295b8a385f6b2d11b8e6
|
|
BLAKE2b-256 checksum How to use checksums |
24e349dd959e7b6c36aa945f621778df8eb93ea874ee80b1b1a8cef78cf6150a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.12.1 Darwin/23.3.0
|
Release files / pvv-1.0.0-py3-none-any.whl
| Download URL | pvv-1.0.0-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4ecdb152c770aa4799f3242cfd5f4f26529aee028f5b3b835629f06fc8f9ce18
|
|
BLAKE2b-256 checksum How to use checksums |
030a43fb498e5887532a6072ce25ffc5122133ba0e73689a6fdcb9d7140fc057
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.12.1 Darwin/23.3.0
|
Security for pvv 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.