Arg Check
A Python utility for checking that call args have the expected types and all required args are provided.
Works only with Python 3.7 (fixing that soon)
Installation
pip install arg-check
Usage
This library uses simple decorators.
Argument Type Checking
@enforce_arg_types
def foobar(a: int, b: str):
...
- Type checking is performed via the annotations. If an argument does not have an annotation, type checking is skipped just for that argument.
- If an argument is a collection, all items in the collection are checked.
- Can handle
UnionandOptional
Required Arguments
@required_args("a", "b")
def foobar(a, b, c=None):
...
- Tests the given arguments and raises a
ValueErrorif the value is eitherNoneor an empty string - To make all arguments required, use
@required_argswithout parenthesis
All checks in one decorator
@strict_args
def foobar(a: int, b: str):
...
- All arguments are type checked
- All arguments are required
Metadata
Release files for argument-checks 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| argument-checks-0.1.1.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| argument_checks-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.4 kB
Release files / argument-checks-0.1.1.tar.gz
| Download URL | argument-checks-0.1.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e4648a2de088464fdec091e45a07afe9af4039653806f2a03073edae59619a00
|
|
BLAKE2b-256 checksum How to use checksums |
12d2d6ee0df0cc522b24632e9f73a28f69f70c0397573a67a0c3692f30ee0f7d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.7.12 Linux/4.4.0-19041-Microsoft
|
Release files / argument_checks-0.1.1-py3-none-any.whl
| Download URL | argument_checks-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bac4006f6f051f7bb39e566630f4a0f9c8f279ff9495bf47733232e4b8573538
|
|
BLAKE2b-256 checksum How to use checksums |
bd97624df0e983d0431fc3a071d26745ca759ab380425c565ffdc257610e0db1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.7.12 Linux/4.4.0-19041-Microsoft
|