Add requirements to function arguments using simple and elegant decorators
Installation:
pip install argreq
Examples
from argreq import argument, requirement
@argument('a', '>10', type=int)
def int_grater_than_10(a):
'''If a is smaller than 10, function raises 'NotValidArgumentError' '''
print(f'a ({a}) is int and larger then 10!')
@argument('a', ('>10', '<20'), type=int)
def other_func(a):
'''Check if a is grater than 10 AND smaller than 20'''
print(f'a {a} is int and between 10 and 20')
@argument('a', '10<{}<20', type=int)
def prettier_other_func(a):
'''Same as above but in a single requirement'''
print(f'a ({a}) is int and between 10 and 20 and prettier ;)')
@argument('a','>0')
@argument('b','>0')
def div(a,b):
'''Check if both a and b positive'''
print(f'{a}/{b}={a/b}')
@argument('d', '"a" in {}', type=dict)
def dict_func(d):
'''Check if d has the key 'a' '''
print(f'd ({d}) has "a" in it')
@requirement('{a}>{b}>0')
def a_grater_than_b_and_positives(a, b):
'''Check if a is grater then b and both positives'''
print(f'{a} > {b}')
Metadata
Release files for argreq 0.2.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 | |
|---|---|---|---|---|
| argreq-0.2.0.tar.gz | 7.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| argreq-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.2 kB
Release files / argreq-0.2.0.tar.gz
| Download URL | argreq-0.2.0.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9da1fee24525436f0bc1e8a6a56c868537f4e44e954e094287e32d6e6dd35680
|
|
BLAKE2b-256 checksum How to use checksums |
1fd032ff76f9d2e7bf6a84fa81e336ccd12fa8c48b501fe9b536c10a6181994a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5
|
Release files / argreq-0.2.0-py3-none-any.whl
| Download URL | argreq-0.2.0-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e8b344916c73e0e522bb297e58c0cedc7920e7caf295a709576fb049d299301c
|
|
BLAKE2b-256 checksum How to use checksums |
93963081b97322eb4b82fdf223082e38091af8723f0c629692038c9280491c1a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/56.0.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5
|
Security for argreq 0.2.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.