Skip to main content

@accepts decorator to check arguments types

Project description

https://img.shields.io/badge/Language-Python-blue.svg?style=plastic https://img.shields.io/pypi/pyversions/accepts.svg

https://codeclimate.com/github/russianidiot/accepts.py/badges/gpa.svg https://landscape.io/github/russianidiot/accepts.py/master/landscape.svg?style=flat https://scrutinizer-ci.com/g/russianidiot/accepts.py/badges/quality-score.png?b=master

Features

  • support multiple types argument

  • support None argument

  • human readable detailed exception message

Usage

>>> from accepts import accepts

>>> @accepts(arg1type,arg2type,...)

Examples

>>> @accepts(int)
def inc(value):
        return value+1

>>> inc(1) # ok
>>> inc(1.5) # exception
TypeError: ....

# multiple types
>>> @accepts((int,float))

# None
>>> @accepts((int,float,None))

Feedback github_follow github_issues

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

accepts-0.0.51.tar.gz (2.8 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page