{"id":23869,"library":"hypothesmith","title":"hypothesmith","description":"Hypothesis strategies for generating Python programs, similar to CSmith. Current version 0.3.3; release cadence is low, mostly bugfixes. Requires Python >= 3.8.","status":"active","version":"0.3.3","language":"python","source_language":"en","source_url":"https://github.com/Zac-HD/hypothesmith","tags":["hypothesis","testing","fuzzing","grammar","python"],"install":[{"cmd":"pip install hypothesmith","lang":"bash","label":"Install from PyPI"}],"dependencies":[{"reason":"Core dependency for property-based testing strategies","package":"hypothesis","optional":false}],"imports":[{"note":"Common mistake: using module-level access instead of direct import; direct import is idiomatic.","wrong":"import hypothesmith; hypothesmith.from_grammar","symbol":"from hypothesmith import from_grammar","correct":"from hypothesmith import from_grammar"},{"note":"Version is stored as __version__ not version.","wrong":"from hypothesmith import version","symbol":"from hypothesmith import from_grammar","correct":"from hypothesmith import from_grammar, __version__"}],"quickstart":{"code":"from hypothesmith import from_grammar\nfrom hypothesis import given, strategies as st\n\n# Generate a simple expression using Python's grammar\n@given(from_grammar('<eval_input>', start='<eval_input>'))\ndef test_parse(code):\n    assert isinstance(code, str)\n    assert len(code) > 0\n\ntest_parse()","lang":"python","description":"Generate Python code strings from grammar rules; use with Hypothesis to fuzz parsers or interpreters."},"warnings":[{"fix":"Use '<stmt>' not 'stmt' when passing to from_grammar.","message":"The grammar strings use angle brackets around rule names (e.g., '<stmt>'), not just the rule name.","severity":"gotcha","affected_versions":"all"},{"fix":"Use from_grammar() instead of from_node().","message":"from_grammar() replaces the older from_node() API; from_node may be removed in future versions.","severity":"deprecated","affected_versions":">=0.3.0"},{"fix":"Combine with Hypothesis strategies to generate valid names or use custom filters.","message":"Generated code may be syntactically correct but semantically invalid (e.g., referencing undefined names).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Run 'pip install hypothesmith'.","cause":"hypothesmith not installed.","error":"ModuleNotFoundError: No module named 'hypothesmith'"},{"fix":"Ensure you use 'from hypothesmith import from_grammar' and pass valid grammar rules.","cause":"Incorrect import path; from_grammar returns a strategy but may be called incorrectly.","error":"hypothesis.errors.InvalidArgument: Expected a strategy, got ..."},{"fix":"Use 'from hypothesmith import from_grammar' instead of from_node.","cause":"Using an older API that was removed or renamed.","error":"AttributeError: module 'hypothesmith' has no attribute 'from_node'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}