ycontract
Python library for contracts testing.
This library provides functions for checking argument(in_contract) and return value(out_contract) of a function.
How to install
$ pip install ycontract
Example
Example files are here(test file)
Main example is
from ycontract import contract, out_contract
@contract(lambda a, b: a * b > 0)
def add(a, b, c):
return a + b
@contract(returns=lambda res: res > 0)
def sub(a, b):
return a - b
And more complex example about in_contract is
@contract(
lambda a0: a0 > 0,
lambda a1, b: a1 > 0 and b > 0,
{
"a2": lambda x: x > 0,
"a3": [
lambda x: x >= 0,
lambda x: x < 4,
],
("a4", "a5"): lambda x, y: x > 0 and y > 0,
},
b=lambda x: x > 0,
contract_tag="tagtag",
)
def add_for_complex(a0, a1, a2, a3, a4, a5, b=1):
return a0 + a1 + a2 + a3 + a4 + a5 + b
Furthermore if you want to be disable, call
ycontract.disable_contract()
LICENSES
Metadata
Release files for ycontract 0.3.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ycontract-0.3.3.2.tar.gz | 10.2 kB | Without provenance | Details for ycontract-0.3.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ycontract-0.3.3.2-py3-none-any.whl | Python 3 | none | any | Details for ycontract-0.3.3.2-py3-none-any.whl |
Total release size: 21.7 kB
Release files / ycontract-0.3.3.2.tar.gz
| Download URL | ycontract-0.3.3.2.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dfe0859180ad94825f7e0a858c3425d698a24d4b1646b421930d0b4d3bdbb46a
|
|
BLAKE2b-256 checksum How to use checksums |
a6dc3e175a2908c92187303174d6c4754b059b7261beb2e2a4a4eb2566355890
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.10 CPython/3.9.0b5 Darwin/19.3.0
|
Release files / ycontract-0.3.3.2-py3-none-any.whl
| Download URL | ycontract-0.3.3.2-py3-none-any.whl |
|---|---|
| Size | 11.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bb9770cdc2cc4d895b5a41d49d5283369525176928fa8d770a0e582dad48985e
|
|
BLAKE2b-256 checksum How to use checksums |
5688ef09a5688d219cd70a924328eda74113b530ae31fa30194f2d57a3b264b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.10 CPython/3.9.0b5 Darwin/19.3.0
|
Security for ycontract 0.3.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.