--- id: deal version: "4.24.6" license: unclear license_treatment: permissive maintenance: aging --- # deal — **Deal** is a Python library for [design by contract][wiki] (DbC) programming. License: permissive · Maintenance: aging · Downloads: 97.1K/mo ## What it is and what it does Deal is a design-by-contract library that lets you annotate Python functions with decorators to declare expected behavior: what inputs are valid (preconditions), what outputs must satisfy (postconditions), what invariants must hold, and what side-effects are allowed. Once annotated, the same contract declarations power multiple verification modes—runtime checking, static linting via flake8, property-based test generation, and formal verification—without requiring separate test code. The library has zero runtime dependencies, so you can add contracts during development and leave them enabled or disabled in production. Deal integrates with pytest, flake8, sphinx, and hypothesis, and supports type annotations. It tracks exceptions and side-effects, detects memory leaks in pure functions, and performs partial execution to statically check possible values. The package has been in production use since 2018 and is actively maintained, though the last release was several months ago. Use it for: - Add precondition and postcondition decorators to functions to catch invalid inputs and outputs early in development. - Generate property-based tests automatically from contract decorators using deal.cases() integration. - Run static contract checking via flake8 or deal's built-in linter to find violations before runtime. - Enforce that functions are pure (no side-effects) and detect unexpected memory retention in pure functions. - Formally verify critical code paths to prove correctness for all possible inputs. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Deal is a Python library for design by contract that adds decorators to enforce preconditions, postconditions, invariants, and side-effect tracking, enabling static analysis, property-based testing, and runtime verification. Yes, with conditions. Deal is worth installing if you want to add design-by-contract discipline to Python code and benefit from both runtime and static verification. The zero-dependency runtime, production track record since 2018, and integration with standard tools (pytest, flake8) make it low-risk to adopt. However, the aging maintenance status (257 days since last release) means you should verify that the version works with your Python version and toolchain before committing to it in a new project. ## Install pip install deal uv add deal poetry add deal ## Installing deal Before you install: Low install friction with no runtime dependencies. The package is in production use since 2018 and has 903 repository stars, but maintenance status is aging—last release was 257 days ago. License in practice: Deal is permissively licensed, allowing use in both open-source and proprietary projects without significant legal constraints. Quickstart: pip install deal import deal @deal.post(lambda result: result >= 0) @deal.pure def count(items, item): return items.count(item) test_count = deal.cases(count) Requires Python 3.8 or later. Verify before relying: - Whether the 100% test coverage claim and partial formal verification are current as of version 4.24.6. - Performance characteristics and overhead of contract checking at runtime versus static analysis only. - Current state of integration with pytest, flake8, sphinx, and hypothesis in this version. ## Package facts - License: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: aging - Downloads: 97.1K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags design by contract decorators, precondition postcondition validation, python contract testing, side-effect tracking library, formal verification python, property-based testing framework, static contract checker, design-by-contract, formal-verification, testing-framework [View on SkillFed](https://skillfed.io/packages/deal) · [View on PyPI](https://pypi.org/project/deal/)