Skip to main content

A python function parameter and return type-checking decorator

Project description

# Complaince
A python function parameter and return type-checking decorator

Both the parameters types and return type(optional to check for return type)
can be done using a single decorator.

Each parameter can have multiple possible types , mentioned in a tuple


pip install complaince

When plainly checking parameter types

def myfunc(a, b):
This indicates the parameters a,b can be either int or float

def myfunc(a, b):
In this case both a and b have to be int only (tuple definition is a must )

There is are two optional parameters:

1. level - Key-Value pair indicates warning message to stderr or throw an exception (0 - warning , 1 - exception error) Default
is warning i.e 0

2. ret - Key-Value pair indicating possible return types, in this case too
value is a tuple

@param_check((int,float),(int,float), level = 1, ret = (int,float))
def myfunc(a, b)
In the above example we will throw an exception if the parameters, return value do not match
required types. Return value can be either an in or float

Requires python 2.6 or higher
Works with python 3.0 and higher

Project details

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
complaince- (5.0 kB) Copy SHA256 hash SHA256 Wheel py2.py3

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page