{"id":45522917,"url":"https://github.com/t3rn0/ast-comments","last_synced_at":"2026-02-22T23:19:47.035Z","repository":{"id":52565861,"uuid":"514955615","full_name":"t3rn0/ast-comments","owner":"t3rn0","description":"Extension to the built-in ast module. Finds comments in source code and adds them to the parsed tree.","archived":false,"fork":false,"pushed_at":"2025-06-29T09:59:09.000Z","size":46,"stargazers_count":46,"open_issues_count":4,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-02T01:09:14.474Z","etag":null,"topics":["ast","comments","library","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/t3rn0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-07-17T21:06:02.000Z","updated_at":"2025-08-29T15:00:39.000Z","dependencies_parsed_at":"2023-02-08T19:00:53.780Z","dependency_job_id":"b67fd591-3041-4944-9103-aba605332892","html_url":"https://github.com/t3rn0/ast-comments","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":0.3846153846153846,"last_synced_commit":"aa429e4d6cdea09ce286e064885d4aa4e9ad84f9"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/t3rn0/ast-comments","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t3rn0%2Fast-comments","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t3rn0%2Fast-comments/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t3rn0%2Fast-comments/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t3rn0%2Fast-comments/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/t3rn0","download_url":"https://codeload.github.com/t3rn0/ast-comments/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t3rn0%2Fast-comments/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29730534,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T20:09:16.275Z","status":"ssl_error","status_checked_at":"2026-02-22T20:09:13.750Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["ast","comments","library","python"],"created_at":"2026-02-22T23:19:44.409Z","updated_at":"2026-02-22T23:19:47.022Z","avatar_url":"https://github.com/t3rn0.png","language":"Python","readme":"# ast-comments\n\nA Python extension to the built-in `ast` module that preserves comments in the Abstract Syntax Tree.\nThis library finds comments in source code and includes them as nodes in the parsed AST.\n\n## Installation\n```\npip install ast-comments\n```\n\n## Usage\n\nUsage is identical to the standard `ast` module:\n```\n\u003e\u003e\u003e from ast_comments import *\n\u003e\u003e\u003e tree = parse(\"hello = 'hello' # comment to hello\")\n```\nThe parsed tree is an instance of the original `ast.Module` object.\nThe only difference is that there is a new type of tree node: `Comment`.\n```\n\u003e\u003e\u003e tree\n\u003c_ast.Module object at 0x7ffba52322e0\u003e\n\u003e\u003e\u003e tree.body\n[\u003cast.Assign object at 0x10a01d5b0\u003e, \u003cast_comments.Comment object at 0x10a09e0a0\u003e]\n\u003e\u003e\u003e tree.body[1].value\n'# comment to hello'\n\u003e\u003e\u003e dump(tree)\n\"Module(body=[Assign(targets=[Name(id='hello', ctx=Store())], value=Constant(value='hello')), Comment(value='# comment to hello', inline=True)], type_ignores=[])\"\n```\nIf you have Python 3.9 or above, you can also unparse the tree object with its comments preserved:\n```\n\u003e\u003e\u003e print(unparse(tree))\nhello = 'hello'  # comment to hello\n```\n**Note**: Python's `compile()` function cannot be used directly on the parsed tree output. The included `pre_compile_fixer()` function can be used to prepare the tree for compilation by stripping comment nodes when needed.\n\nAdditional examples can be found in the test files: `test_parse.py` and `test_unparse.py`.\n\n## Contributing\nContributions are welcome! Please feel free to open an issue or create a pull request.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft3rn0%2Fast-comments","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft3rn0%2Fast-comments","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft3rn0%2Fast-comments/lists"}