{"id":13743220,"url":"https://github.com/mutpy/astmonkey","last_synced_at":"2025-10-29T07:13:45.934Z","repository":{"id":12364915,"uuid":"15014574","full_name":"mutpy/astmonkey","owner":"mutpy","description":"Set of tools to play with Python AST.","archived":false,"fork":false,"pushed_at":"2022-09-27T12:47:06.000Z","size":193,"stargazers_count":87,"open_issues_count":3,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-10-10T00:43:59.688Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mutpy.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-07T23:07:35.000Z","updated_at":"2025-07-28T00:29:49.000Z","dependencies_parsed_at":"2022-09-25T21:38:38.470Z","dependency_job_id":null,"html_url":"https://github.com/mutpy/astmonkey","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/mutpy/astmonkey","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutpy%2Fastmonkey","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutpy%2Fastmonkey/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutpy%2Fastmonkey/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutpy%2Fastmonkey/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mutpy","download_url":"https://codeload.github.com/mutpy/astmonkey/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mutpy%2Fastmonkey/sbom","scorecard":{"id":668916,"data":{"date":"2025-08-11","repo":{"name":"github.com/mutpy/astmonkey","commit":"16b1817fd022b60b1369281af74b465db6db85ff"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.6,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/19 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 15 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-21T19:14:22.415Z","repository_id":12364915,"created_at":"2025-08-21T19:14:22.415Z","updated_at":"2025-08-21T19:14:22.415Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280333492,"owners_count":26312845,"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","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-08-03T05:00:42.717Z","updated_at":"2025-10-21T20:52:55.445Z","avatar_url":"https://github.com/mutpy.png","language":"Python","funding_links":[],"categories":["Tools"],"sub_categories":[],"readme":"=========\nastmonkey\n=========\n\n|Python Versions| |Build Status| |Coverage Status| |Code Climate|\n\n``astmonkey`` is a set of tools to play with Python AST.\n\nInstallation\n------------\n\nYou can install ``astmonkey`` from PyPI:\n\n::\n\n    $ pip install astmonkey\n\nIf you want to have latest changes you should clone this repository and use ``setup.py``:\n\n::\n\n    $ git clone https://github.com/mutpy/astmonkey.git\n    $ cd astmonkey\n    $ python setup.py install\n\nvisitors.SourceGeneratorNodeVisitor\n-----------------------------------\n\nThis visitor allow AST to Python code generation. It was originally written by\nArmin Ronacher (2008, license BSD) as ``codegen.py`` module. ``astmonkey`` version\nfixes few bugs and it has good code coverage.\n\nExample usage:\n\n::\n\n    import ast\n    from astmonkey import visitors\n\n    code = 'x = (y + 1)'\n    node = ast.parse(code)\n    generated_code = visitors.to_source(node)\n\n    assert(code == generated_code)\n\ntransformers.ParentChildNodeTransformer\n---------------------------------------\n\nThis transformer adds few fields to every node in AST:\n\n* ``parent`` - link to parent node,\n* ``parents`` - list of all parents (only ``ast.expr_context`` nodes have more than one parent node, in other causes this is one-element list),\n* ``parent_field`` - name of field in parent node including child node,\n* ``parent_field_index`` - parent node field index, if it is a list.\n* ``children`` - link to children nodes.\n\nExample usage:\n\n::\n    \n    import ast\n    from astmonkey import transformers\n\n    node = ast.parse('x = 1')\n    node = transformers.ParentChildNodeTransformer().visit(node)\n\n    assert(node == node.body[0].parent)\n    assert(node.body[0].parent_field == 'body')\n    assert(node.body[0].parent_field_index == 0)\n    assert(node.body[0] in node.children)\n\nvisitors.GraphNodeVisitor\n-------------------------\n\nThis visitor creates Graphviz graph from Python AST (via ``pydot``). Before you use \n``GraphNodeVisitor`` you need to add parents links to tree nodes (with \n``ParentChildNodeTransformer``).\n\nExample usage:\n\n::\n\n    import ast\n    from astmonkey import visitors, transformers\n\n    node = ast.parse('def foo(x):\\n\\treturn x + 1')\n    node = transformers.ParentChildNodeTransformer().visit(node)\n    visitor = visitors.GraphNodeVisitor()\n    visitor.visit(node)\n\n    visitor.graph.write_png('graph.png')\n\nProduced ``graph.png`` (you need to have installed ``graphviz`` binaries if you want generate \nimages):\n\n.. image:: examples/graph.png\n\nutils.is_docstring\n------------------\n\nThis routine checks if target node is a docstring. Before you use \n``is_docstring`` you need to add parents links to tree nodes (with \n``ParentChildNodeTransformer``).\n\nExample usage:\n\n::\n\n    import ast\n    from astmonkey import utils, transformers\n\n    node = ast.parse('def foo(x):\\n\\t\"\"\"doc\"\"\"')\n    node = transformers.ParentChildNodeTransformer().visit(node)\n\n    docstring_node = node.body[0].body[0].value\n    assert(not utils.is_docstring(node))\n    assert(utils.is_docstring(docstring_node))\n\n\nLicense\n-------\n\nCopyright [2013] [Konrad Hałas]\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n   http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n\n..  |Python Versions| image:: https://img.shields.io/pypi/pyversions/astmonkey.svg\n    :target: https://github.com/mutpy/astmonkey\n..  |Build Status| image:: https://travis-ci.org/mutpy/astmonkey.png\n    :target: https://travis-ci.org/mutpy/astmonkey\n.. |Coverage Status| image:: https://coveralls.io/repos/github/mutpy/astmonkey/badge.svg?branch=master\n   :target: https://coveralls.io/github/mutpy/astmonkey?branch=master\n.. |Code Climate| image:: https://codeclimate.com/github/mutpy/astmonkey/badges/gpa.svg\n   :target: https://codeclimate.com/github/mutpy/astmonkey\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmutpy%2Fastmonkey","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmutpy%2Fastmonkey","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmutpy%2Fastmonkey/lists"}