Skip to main content

@accepts decorator to check arguments types

Project description

https://img.shields.io/badge/language-python-blue.svg https://img.shields.io/pypi/pyversions/accepts.svg

codacy.com landscape.io codeclimate.com scrutinizer-ci.com

Install

[sudo] pip install accepts

Features

  • support multiple types argument

  • support None argument

  • human readable detailed exception message

Usage

>>> from accepts import accepts

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

Example

>>> @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))

Examples/

Sources:

Feedback github_issues gitter github_follow


russianidiot.github.io/python/ - Python packages

russianidiot.github.io/cli/ - command line scripts

README.rst - generated with readmemako.py (python+ mako templates) and .README dotfiles

Project details


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.19.tar.gz (7.1 kB view details)

Uploaded Source

File details

Details for the file accepts-0.0.19.tar.gz.

File metadata

  • Download URL: accepts-0.0.19.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for accepts-0.0.19.tar.gz
Algorithm Hash digest
SHA256 5c1a99e7b23dba34c4779a79d984243c87e1d22d9815ea7298e0974ac18d2347
MD5 ac9fe19db967ef95cfcdc846a9bb69e6
BLAKE2b-256 747c2f069b369f48e7408cd8d395ff4c886b3bae07812345dcc5923dcc5e2628

See more details on using hashes here.

Supported by

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