utility for checking that call args have the expected types and all required args are provided
Project description
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
Union
andOptional
Required Arguments
@required_args("a", "b")
def foobar(a, b, c=None):
...
- Tests the given arguments and raises a
ValueError
if the value is eitherNone
or an empty string - To make all arguments required, use
@required_args
without parenthesis
All checks in one decorator
@strict_args
def foobar(a: int, b: str):
...
- All arguments are type checked
- All arguments are required
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
argument-checks-0.1.1.tar.gz
(4.9 kB
view details)
Built Distribution
File details
Details for the file argument-checks-0.1.1.tar.gz
.
File metadata
- Download URL: argument-checks-0.1.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.7.12 Linux/4.4.0-19041-Microsoft
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4648a2de088464fdec091e45a07afe9af4039653806f2a03073edae59619a00 |
|
MD5 | b50d0d71afb57d95be3608fabc254c6a |
|
BLAKE2b-256 | 12d2d6ee0df0cc522b24632e9f73a28f69f70c0397573a67a0c3692f30ee0f7d |
File details
Details for the file argument_checks-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: argument_checks-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.7.12 Linux/4.4.0-19041-Microsoft
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bac4006f6f051f7bb39e566630f4a0f9c8f279ff9495bf47733232e4b8573538 |
|
MD5 | 8510d55f424b5931b250be2fef4b3f24 |
|
BLAKE2b-256 | bd97624df0e983d0431fc3a071d26745ca759ab380425c565ffdc257610e0db1 |