HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
Parquery
icontract
Python2020–2026
Parquery / icontract

icontract

Design-by-contract in Python3 with informative violation messages and inheritance

4Distinct people
8Mentions
0Explicit recommenders
420GitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Design-by-contract in Python3 with informative violation messages and inheritance

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 8–Nov 15 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/15/2026, 10:02:05 AM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year8 dated mentions

Observed mentions: 2020-12-14 21:43:46 UTC to 2026-03-17 06:11:17 UTC.

0122020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20202021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20232024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2025-01-01 00:00:00 UTC to 2026-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments2026-01-01 00:00:00 UTC to 2027-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments. Incomplete calendar period.2026*

* An incomplete calendar period is marked with an outlined bar. Its count is not directly comparable with a full period.

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC101
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC101
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC000
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC101
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC101
20252025-01-01 00:00:00 UTC2026-01-01 00:00:00 UTC202
2026 (partial)2026-01-01 00:00:00 UTC2027-01-01 00:00:00 UTC202

What Hacker News says

2 sources
Parquery/icontract: https://github.com/Parquery/icontract mristin/icontract-hypothesis: https://github.com/mristin/icontract-hypothesis : > The result is a powerful combination that allows you to automatically test your code. Instead of writing manually the Hypothesis search strategies for a function, icontract-hypothesis infers them based on the function's precondition. This makes automatic testing as effortless as it goes. pschanely/CrossHair: An analysis tool for Python that blurs the line between testing and type systems https://github.com/pschanely/CrossHair : > If you have a function with type annotations and add a contract in a supported syntax, CrossHair will attempt to find counterexamples for you: [gif] > CrossHair works by repeatedly calling your functions with symbolic inputs. It uses an SMT solver (a kind of theorem prover)
Read the rest
to explore viable execution paths and find counterexamples for you
In Comparing Python Type Checkers: Typing Spec Conformance
- /?hnlog pycontract icontract https://westurner.github.io/hnlog/ : From https://news.ycombinator.com/item?id=14246095 (2017) : > PyContracts supports runtime type-checking and value constraints/assertions (as @contract decorators, annotations, and docstrings). > Unfortunately, there's yet no unifying syntax between PyContracts and the newer python type annotations which MyPy checks at compile-type. Or beartype. Pycontracts has: https://andreacensi.github.io/contracts/ : @contract def my_function(a : 'int,>0', b : 'list[N],N>0') -> 'list[N]': @contract(image='array[HxWx3](uint8),H>10,W>10') def recolor(image): For icontract, there's icontract-hyothesis. parquery/icontract: https://github.com/Parquery/icontract : > There exist a couple of contract libraries. However, at the time of this writing (September 2018), they all requir
Read the rest
ed the programmer either to learn a new syntax (PyContracts) or to write redundant condition descriptions ( e.g., contracts, covenant, deal, dpcontracts, pyadbc and pcd). @icontract.require(lambda x: x > 3, "x must not be small") def some_func(x: int, y: int = 5) -> None: icontract with numpy array types: @icontract.require(lambda arr: isinstance(arr, np.ndarray)) @icontract.require(lambda arr: arr.shape == (3, 3)) @icontract.require(lambda arr: np.all(arr >= 0), "All elements must be non-negative") def process_matrix(arr: np.ndarray): return np.sum(arr) invalid_matrix = np.array([[1, -2, 3], [4, 5, 6], [7, 8, 9]]) process_matrix(invalid_matrix) # Raises icontract.ViolationError
In Comparing Python Type Checkers: Typing Spec Conformance

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.