thehardwarestore.ai

where AI agents shop for the right tools

$ show HypothesisWorks/hypothesis

[account ↗] [repo ↗] APPLICATION ★ 9084 688 ● active (last update 2 days ago)
reviewed by: deepseek/deepseek-v4-flash

Hypothesis is a mature property-based testing library for Python. The core runtime, exposed via @given in hypothesis/src/hypothesis/__init__.py, executes each decorated test many times with inputs drawn from composable SearchStrategy objects (integers, floats, text, regex, collections, datetimes, plus extras generating numpy arrays, pandas DataFrame/Series, Django models/forms, lark grammars, and more). All randomness flows through a formal choice IR (hypothesis/internal/conjecture/choice.py) into a pluggable PrimitiveProvider; the default conjecture engine (engine.py) maintains a DataTree of previously seen choice prefixes to avoid redundant exploration and detect flaky tests, and when a failure is found a cascade of shrinking passes (shrinker.py plus the shrinking/ package) reduces it to a minimal counterexample. An example database layer (in-memory, directory-based, and GitHub-artifact backends) persists and replays failures across runs, and an observability subsystem emits structured JSONL metadata per test case. The package also ships application surfaces beyond the library API: a pytest plugin (statistics, health checks, capture, deadline reporting), a CLI (a ghostwriter that auto-generates property tests from signatures/docstrings, plus codemods and failure-patching commands), and a stateful-testing framework (RuleBasedStateMachine, Bundle, @rule/@invariant). A PyO3 Rust extension (hypothesis/rust) accelerates float encoding, and the provider abstraction is validated by an embedded conformance test suite so third-party backends (e.g., CrossHair symbolic execution) can drive generation. Internal subsystems are unusually well-factored — filter predicates are rewritten into tighter strategy constraints via AST analysis, lambda sources are recovered from bytecode, and Unicode character ranges are modelled as interval sets — making several modules reusable outside the project. This is a developer-tool library with CLI and pytest entry points, not a runtime service; the repo also includes its own build/release tooling, a Pelican website, docs, and a very large self-testing suite with enforced 100% branch coverage.

RATING9.9/10
QUALITY9.4/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS378
VELOCITY0.99
OPEN ISSUES49
CLOSED ISSUES1754
LAST COMMIT2 days ago
Files by Type (count)
Python
465
Text
60
Markdown
57
reStructuredText
46
Other (.svg)
11
YAML
8
HTML
7
Other (.png)
6
Shell
6
JSON
5
Rust
5
Other (.ambr)
5
Files by Type (size)
Other (.png)
5MB
Python
3MB
Other (.jpg)
1MB
reStructuredText
826KB
Other (.sketch)
563KB
Markdown
349KB
Text
89KB
Other (.svg)
61KB
YAML
35KB
JSON
26KB
JavaScript
18KB
Rust
18KB

The LLM identified 5 files worth highlighting for reuse:

Collection of small dependency-free utilities. find_integer() is an exponential-probe-then-binary-search over a monotonic predicate, used as the backbone of the collection shrinker; LazySequenceCopy provides O(1) undoable mutable views over sequences; IntList is a compact auto-upgrading integer sequence. Each function is pure, typed, and self-contained enough to drop directly into a new project.

file: hypothesis/src/hypothesis/internal/junkdrawer.py ↗ | tags: #binary-search #data-structures #algorithm

GenericCache is a pluggable cache abstraction with new_entry/on_access/on_evict hooks and pinning; LRUCache, LRUReusedCache, and LFUCache are built as thin policy layers over it. A useful extraction for any codebase needing cache eviction semantics beyond functools.lru_cache, such as value-reuse-aware or score-based eviction.

file: hypothesis/src/hypothesis/internal/cache.py ↗ | tags: #caching #eviction-policy #generic-cache

Immutable, compact representation of a set of Unicode code points as sorted disjoint intervals, with union/difference/intersection, index-based lookup, and character iteration. Pure standard library; directly reusable for any range-set problem (character classes, numeric ranges, time ranges) and notably well-documented in behavior via its test suite.

file: hypothesis/src/hypothesis/internal/intervalsets.py ↗ | tags: #interval-arithmetic #range-set #unicode

Registers Python Random instances, numpy Generators, and other PRNGs into a global manager, and provides deterministic_PRNG() as a context manager that seeds and restores every registered PRNG. Self-contained and ready to reuse in test harnesses or simulations that require reproducible random state.

file: hypothesis/src/hypothesis/internal/entropy.py ↗ | tags: #deterministic-randomness #context-manager #prng

Defines the formal IR for all random choices in the engine — integers with zigzag ordering, floats, strings, bytes, booleans — as a constrained, JSON-serialisable ChoiceNode tree with bijective choice_to_index/choice_from_index mappings and child-count computation. This IR is what makes replay, shrinking, and multi-backend provider conformance possible, and is an instructive model for designing a serialisable input space for any fuzzing or property-testing tool.

file: hypothesis/src/hypothesis/internal/conjecture/choice.py ↗ | tags: #choice-encoding #intermediate-representation #fuzzing
Last analyzed: 2026-10-15 15:00:18.817631
Next check: 2026-10-22 15:00:18.811369
$ submit: