{"id":15440488,"url":"https://github.com/zac-hd/hypothesmith","last_synced_at":"2025-04-07T12:07:13.549Z","repository":{"id":35050673,"uuid":"200747543","full_name":"Zac-HD/hypothesmith","owner":"Zac-HD","description":"Hypothesis strategies for generating Python programs, something like CSmith","archived":false,"fork":false,"pushed_at":"2024-02-16T19:42:25.000Z","size":97,"stargazers_count":100,"open_issues_count":10,"forks_count":10,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-31T10:07:00.115Z","etag":null,"topics":["fuzzing","hypothesis","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/hypothesmith/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zac-HD.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"Zac-HD","tidelift":"pypi/hypothesmith"}},"created_at":"2019-08-06T00:28:21.000Z","updated_at":"2025-03-29T16:24:26.000Z","dependencies_parsed_at":"2024-01-13T16:33:16.598Z","dependency_job_id":"2ab9c4d3-a134-40fb-8eff-e089aec7dc2e","html_url":"https://github.com/Zac-HD/hypothesmith","commit_stats":{"total_commits":60,"total_committers":3,"mean_commits":20.0,"dds":"0.16666666666666663","last_synced_commit":"148dc61c46d2f9d20eb4c11911ebb11ad3f6a5f0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zac-HD%2Fhypothesmith","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zac-HD%2Fhypothesmith/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zac-HD%2Fhypothesmith/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zac-HD%2Fhypothesmith/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zac-HD","download_url":"https://codeload.github.com/Zac-HD/hypothesmith/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247648977,"owners_count":20972945,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fuzzing","hypothesis","python"],"created_at":"2024-10-01T19:13:47.289Z","updated_at":"2025-04-07T12:07:13.525Z","avatar_url":"https://github.com/Zac-HD.png","language":"Python","funding_links":["https://github.com/sponsors/Zac-HD","https://tidelift.com/funding/github/pypi/hypothesmith"],"categories":[],"sub_categories":[],"readme":"# hypothesmith\nHypothesis strategies for generating Python programs, something like CSmith.\n\nThis is definitely pre-alpha, but if you want to play with it feel free!\nYou can even keep the shiny pieces when - not if - it breaks.\n\nGet it today with [`pip install hypothesmith`](https://pypi.org/project/hypothesmith/),\nor by cloning [the GitHub repo](https://github.com/Zac-HD/hypothesmith).\n\nYou can run the tests, such as they are, with `tox` on Python 3.6 or later.\nUse `tox -va` to see what environments are available.\n\n## Usage\nThis package provides two Hypothesis strategies for generating Python source code.\n\nThe generated code will always be syntatically valid, and is useful for testing\nparsers, linters, auto-formatters, and other tools that operate on source code.\n\n\u003e DO NOT EXECUTE CODE GENERATED BY THESE STRATEGIES.\n\u003e\n\u003e It could do literally anything that running Python code is able to do,\n\u003e including changing, deleting, or uploading important data.  Arbitrary\n\u003e code can be useful, but \"arbitrary code execution\" can be very, very bad.\n\n#### `hypothesmith.from_grammar(start=\"file_input\", *, auto_target=True)`\n\nGenerates syntactically-valid Python source code based on the grammar.\n\nValid values for ``start`` are ``\"single_input\"``, ``\"file_input\"``, or\n``\"eval_input\"``; respectively a single interactive statement, a module or\nsequence of commands read from a file, and input for the eval() function.\n\nIf ``auto_target`` is ``True``, this strategy uses ``hypothesis.target()``\ninternally to drive towards larger and more complex examples.  We recommend\nleaving this enabled, as the grammar is quite complex and only simple examples\ntend to be generated otherwise.\n\n#### `hypothesmith.from_node(node=libcst.Module, *, auto_target=True)`\n\nGenerates syntactically-valid Python source code based on the node types\ndefined by the [`LibCST`](https://libcst.readthedocs.io/en/latest/) project.\n\nYou can pass any subtype of `libcst.CSTNode`.  Alternatively, you can use\nHypothesis' built-in `from_type(node_type).map(lambda n: libcst.Module([n]).code`,\nafter Hypothesmith has registered the required strategies.  However, this does\nnot include automatic targeting and limitations of LibCST may lead to invalid\ncode being generated.\n\n## Notable bugs found with Hypothesmith\n- [BPO-40661, a segfault in the new parser](https://bugs.python.org/issue40661),\n  was given maximum priority and blocked the planned release of CPython 3.9 beta1.\n- [BPO-38953](https://bugs.python.org/issue38953) `tokenize` -\u003e `untokenize` roundtrip bugs.\n- [BPO-42218](https://bugs.python.org/issue42218) mishandled error case in new PEG parser.\n- [`lib2to3` errors on \\r in comment](https://github.com/psf/black/issues/970)\n- [Black fails on files ending in a backslash](https://github.com/psf/black/issues/1012)\n- [At least three round-trip bugs in LibCST](https://github.com/Instagram/LibCST#acknowledgements)\n  ([search commits for \"hypothesis\"](https://github.com/Instagram/LibCST/search?q=Fix+hypothesis\u0026type=commits))\n- [Invalid code generated by LibCST](https://github.com/Instagram/LibCST/issues/287)\n\n### Changelog\n\nPatch notes [can be found in `CHANGELOG.md`](https://github.com/Zac-HD/hypothesmith/blob/master/CHANGELOG.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzac-hd%2Fhypothesmith","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzac-hd%2Fhypothesmith","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzac-hd%2Fhypothesmith/lists"}