Home

Awesome

Deal

Build Status PyPI version Development Status

A Python library for design by contract (DbC) and checking values, exceptions, and side-effects. In a nutshell, deal empowers you to write bug-free code. By adding a few decorators to your code, you get for free tests, static analysis, formal verification, and much more. Read intro to get started.

Features

Deal in 30 seconds

# the result is always non-negative
@deal.post(lambda result: result >= 0)
# the function has no side-effects
@deal.pure
def count(items: List[str], item: str) -> int:
    return items.count(item)

# generate test function
test_count = deal.cases(count)

Now we can:

Read more in the documentation.

Installation

python3 -m pip install --user 'deal[all]'

Contributing

Contributions are welcome! A few ideas what you can contribute:

To run tests locally, all you need is task. Run task all to run all code formatters, linters, and tests.

Thank you :heart: