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

Installation
============

```bash
pip install complaince
```

Examples
========
When plainly checking parameter types

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

```python
@param_check((int,),(int,))
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

```python
@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

Compatability
=============
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.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

complaince-1.0.2.0b0.dev2-py2.py3-none-any.whl (5.0 kB view details)

Uploaded Python 2Python 3

File details

Details for the file complaince-1.0.2.0b0.dev2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for complaince-1.0.2.0b0.dev2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 1822d507ff109bc11ff91bd7f5536df3935688c50d6d091caf62eac0b0b4bfc1
MD5 5b66eea3328a20453b68af4e9962b4bf
BLAKE2b-256 20f0c663a12627dff420147dccd24a82a8f5ed4ae0596f0256ea7a1f7a3175c4

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