Deal -- python library for design by contract (DbC) programming. That's nice assert statements in decorators style to validate function input, output, available operations and object state. Goal is make testing much easier and detect errors in your code that occasionally was missed in tests.
Based on the "Functional Programming" category.
Alternatively, view Deal alternatives based on common mentions on social networks and blogs.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Deal or a related project?
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.
# 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:
python3 -m deal lint or flake8 to statically check errors.python3 -m deal test or pytest to generate and run tests.Read more in the documentation.
python3 -m pip install --user 'deal[all]'
Contributions are welcome! A few ideas what you can contribute:
README.md.To run tests locally, all you need is task. Run task all to run all code formatters, linters, and tests.
Thank you :heart:
Do not miss the trending, packages, news and articles with our weekly report.