{"id":28955512,"url":"https://github.com/pyastrx/pyastrx","last_synced_at":"2025-06-23T20:07:39.728Z","repository":{"id":37941645,"uuid":"492323541","full_name":"pyastrx/pyastrx","owner":"pyastrx","description":"The PyASTrX philosophy is to provide a simple, easy-to-use, and extensible framework for code quality analysis, refactoring and codebase analysis.","archived":false,"fork":false,"pushed_at":"2024-12-23T21:30:53.000Z","size":1119,"stargazers_count":40,"open_issues_count":11,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-21T21:14:09.315Z","etag":null,"topics":["ast","code-analysis","linters","python","refactoring-tools","xml"],"latest_commit_sha":null,"homepage":"https://pyastrx.readthedocs.io/en/latest/","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/pyastrx.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-14T20:55:55.000Z","updated_at":"2025-02-15T00:22:23.000Z","dependencies_parsed_at":"2023-02-19T02:15:43.522Z","dependency_job_id":null,"html_url":"https://github.com/pyastrx/pyastrx","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/pyastrx/pyastrx","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyastrx%2Fpyastrx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyastrx%2Fpyastrx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyastrx%2Fpyastrx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyastrx%2Fpyastrx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pyastrx","download_url":"https://codeload.github.com/pyastrx/pyastrx/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pyastrx%2Fpyastrx/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261508112,"owners_count":23169627,"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":["ast","code-analysis","linters","python","refactoring-tools","xml"],"created_at":"2025-06-23T20:07:35.328Z","updated_at":"2025-06-23T20:07:39.711Z","avatar_url":"https://github.com/pyastrx.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# What is PyASTrX?\n\n\n![](docs/source/_static/imgs/cover_2_w_description.png#gh-light-mode-only)\n![](docs/source/_static/imgs/cover_2_w_description_dark.png#gh-dark-mode-only)\n\n\n\u003ch2 style=\"text-align:center;\"\u003e\n\u003cem style=\"text-align:center;!important\"\u003e\n    \"Simple projects are all alike; each complex project\n    is complex in its own way.\"\n\u003c/em\u003e-\n\u003cstrong\u003e\n    (adapted from Tolstoy's Anna Karenina)\n\u003c/strong\u003e\n\u003c/h2\u003e\n\nThe PyASTrX philosophy is to provide a simple, easy-to-use, and\nextensible framework for code quality analysis, refactoring, and codebase analysis.\n\n\nThe main point that I've developed is that sometimes a necessary practice in one project can be a bad practice in another\nproject. In other words, we should walk a mile in someone's shoes before judging the code\nquality of someone else's code.\n\nPyASTrX allows you to define new code analysis patterns using just XPATH\nexpressions. No need to write an extension to use in\nflake8 or pylint!\n\n## Install\n\n```bash\n$ pip install pyastrx\n```\n\n## Features and Characteristics\n\n\nPyASTrX provides the following features:\n\n### An easy customizable code quality analysis tool.\n\nType `pyastrx -h` to see all the options.\n\nYou can also use a `pyastrx.yaml` file to configure the tool.\n\n### Human-friendly\n\n\n#### Search and Linter outputs\n\nIf your codebase or pull request is huge, looking for possible\nmistakes, bad practices or code smells can be a pain, so PyASTrX\nprovides a human-friendly output as default.\n\n![Human friendly outputs](docs/source/_static/imgs/human_outputs.png)\n\n#### Friendly interface\n\n-   autocomplete the previous queries\n-   combo box to select the files\n-   colorized syntax highlighting\n\n![Human friendly outputs](docs/source/_static/imgs/interface.png)\n\n\n### pre-commit\n\n\nCopy the `main.py` available at\n[pyastrx/.pre-commit-hook](https://github.com/devmessias/pyastrx/blob/main/.pre-commit-hook/main.py)\nin your folder and add the following entry in your\n`.pre-commit-config.yaml` file:\n\n```yaml\n - repo: local\n        hooks:\n        - id: pyastrx\n            name: PyASTrX linter\n            entry: ./\u003cLOCATION\u003e/main.py\n            language: script\n            args: [\"-q\"]\n            types: [\"python\"]\n            description: Check for any violations using the pyastrx.yaml config\n```\nLater on, I will ship this to be used in the pre-commit channels.\n\n## VS Code Extension\n\nSoon, I will ship a VS Code extension.\n\n### Explore the AST and XML\n\n\nUsing the **-i** arg or adding a `interactive:\ntrue` in your `pyastrx.yaml` you can explore\nthe AST and XML parsed AST of your code.\nThis can be useful to understand your code base and help you to write\nyou custom XPATH queries to be used in your project.\n\n\n### Folder and file explorer\n\n**Start the interactive interface**\n\n``` {.console}\n$ pyastrx -i -d path_to_folder (or just save that in yaml)\n```\n\n**Press f and choose a file**\n\n![Interactive interface](docs/source/_static/imgs/ast_explorer2.png)\n\n**Choose the ast (t), xml (x) or code exploration (o)**\n\n![Interactive interface](docs/source/_static/imgs/ast_explorer3.png)\n\n**Learn!**\n\n![Interactive interface](docs/source/_static/imgs/ast_explorer4.png)\n\n![Interactive interface](docs/source/_static/imgs/ast_explorer5.png)\n\n#### File exploration (one key-press distance)\n\n**Open the interactive with the python file**\n\n``` {.console}\n$ pyastrx -i -f path_to_file (or just save that in yaml)\n```\n\n**Choose the ast (t), xml (x) or code exploration (o)*\n\n## Acknowledgments\n\n\nThis project is possible only because of the work of several\ndevelopers across the following projects:\n\n### lxml\n\n\nOne of the greatest Python libraries downloaded over millions of time.\nPlease, consider doing a donation to the [lxml](https://lxml.de/)\ndevelopers.\n\n\n### astpath\n\n\nThe PyASTrX started with the idea of using the astpath as a dependency,\nbut I've decided to rewrite and redesign it to improve the\nmaintainability and the usability features of PyASTrX.\n[astpath](https://github.com/hchasestevens/astpath) is a great and\nsimple tool developed by [H. Chase\nStevens](http://www.chasestevens.com/).\n\n\n### GAST\n\n\n\n[GAST](https://github.com/serge-sans-paille/gast) is a remarkable\ntool developed by [Serge Sans\nPaille](http://serge.liyun.free.fr/serge/). GAST allows PyASTrX use the\nsame XPATH expressions to analyze different code bases written in\ndifferent python versions.\n\n\n### prompt_toolkit\n\n\nA project created by [Jonathan Slenders](https://github.com/jonathanslenders) that\nprovides a powerful and reliable way to construct command-line interfaces.\n\nThis project has a lot of features, and good documentation and the\nmaintainers keep it well updated.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyastrx%2Fpyastrx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpyastrx%2Fpyastrx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpyastrx%2Fpyastrx/lists"}