Install & Compatibility
Where this runs
tested against v0.3.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 14.352s · 37.3MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.1s · import 13.852s · 38MB
37MB installed
● package 37MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
from hypothesmith import from_grammar
✓ from hypothesmith import from_grammar
✗ import hypothesmith; hypothesmith.from_grammar
Common mistake: using module-level access instead of direct import; direct import is idiomatic.
from hypothesmith import from_grammar
✓ from hypothesmith import from_grammar, __version__
✗ from hypothesmith import version
Version is stored as __version__ not version.
Generate Python code strings from grammar rules; use with Hypothesis to fuzz parsers or interpreters.
from hypothesmith import from_grammar
from hypothesis import given, strategies as st
# Generate a simple expression using Python's grammar
@given(from_grammar('<eval_input>', start='<eval_input>'))
def test_parse(code):
assert isinstance(code, str)
assert len(code) > 0
test_parse()
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'hypothesmith'
hypothesmith not installed.
fixRun 'pip install hypothesmith'.
hypothesis.errors.InvalidArgument: Expected a strategy, got ...
Incorrect import path; from_grammar returns a strategy but may be called incorrectly.
fixEnsure you use 'from hypothesmith import from_grammar' and pass valid grammar rules.
AttributeError: module 'hypothesmith' has no attribute 'from_node'
Using an older API that was removed or renamed.
fixUse 'from hypothesmith import from_grammar' instead of from_node.
Upgrade
Version history
0.3.3latest on PyPI · released Feb 16, 2024
Audit
Dependencies
hypothesisrequiredCore dependency for property-based testing strategies