A powerful, expressive and lightweight design-by-contract framework
Project description
ContractMe
A lightweight and adaptable framework for design-by-contract in python
Example code
Here are some examples:
result
@precondition(lambda x: x >= 0)
@postcondition(lambda x, result: eps_eq(result * result, x))
def square_root(x: float) -> float:
return x**0.5
old
@precondition(lambda l, n: n >= 0 and round(n) == n)
@postcondition(lambda l, n: len(l) > 0)
@postcondition(lambda l, n: l[-1] == n)
@postcondition(lambda l, n, old: l[:-1] == old.l)
def append_count(l: list[int], n: int):
l.append(n)
Test
uv run pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
contractme-1.0.0.tar.gz
(13.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file contractme-1.0.0.tar.gz.
File metadata
- Download URL: contractme-1.0.0.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6546f7dad884a97188fed97f7134f6909699def2311e71d2e60fd61813dc596e
|
|
| MD5 |
ce710f04ec7736c17a6cb00243e7f414
|
|
| BLAKE2b-256 |
f3986461d26f6d7a2d5d91c922319a4dad5cb6a41a92287956b9aabf70be3756
|
File details
Details for the file contractme-1.0.0-py3-none-any.whl.
File metadata
- Download URL: contractme-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b5a7aafa362b64f2b99f79fdf57040977196499997a8b262d322b3ea5a17a643
|
|
| MD5 |
9f216fa9983a96f7ebaa0ad44cc65e6f
|
|
| BLAKE2b-256 |
52bee6d8fd2a19c40ea2515660f514a9be2f8351517e1dc8785f19f2e9376a2b
|