@accepts decorator to check arguments types
Project description
Installation
$ [sudo] pip install accepts
Features
- support multiple types argument
- support None argument
- human readable detailed exception message
Functions
function | __doc__ |
---|---|
accepts.accepts(*types) |
@accepts decorator |
Examples
>>> from accepts import accepts
>>> @accepts(int)
def inc(value):
return value+1
>>> inc(1) # ok
# multiple types
>>> @accepts((int,float))
>>> inc(1.5) # ok
>>> inc("string")
TypeError: inc() argument #0 is not instance of (<class 'int'>, <class 'float'>)
# None
>>> @accepts((int,float,type(None)))
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
accepts-2019.3.22.tar.gz
(1.8 kB
view hashes)
Built Distribution
Close
Hashes for accepts-2019.3.22-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4135fcf0cec3aa5ca2604a3c7a25c51fa844141b49435f4e938392d9cfabd5b0 |
|
MD5 | bf4af25744f9021e95f398059df8a2fc |
|
BLAKE2b-256 | d40e905a688b763ac87d08706bc9f0e1e285a34bee56af8d1138602e487c2f36 |