Package: pyastrx
What is PyASTrX?Philosophy“Simple projects are all alike; each complex project is complex in its own way.”(adapted from Tolstoy’s Anna Karenina)The PyASTrX philosophy is to provide a simple, easy-to-use, and
extensible framework for code quality analysis, refactoring and codebase analysis.The main point that I’ve developed is that sometimes a necessary practice in one project can be a bad practice in another
project. In other words, we shouldwalk a **mile in **someone’sshoes** before judging the code quality of someone else code.PyASTrX allows you to define new code analysis patterns using just XPATH
expressions. No need to write a parser, create a python file and ship to use in flake8 or pylint!pipinstallpyastrxFeaturesPyASTrX provides the following features:An easy customizable code quality analysis tool.Typepyastrx -hto see all the options.You can also use apyastrx.yamlfile to configure the tool.Human-friendlySearch and Linter outputsIf your codebase or pull request is huge, looking for possible
mistakes, bad practices or code smells can be a pain, so PyASTrX
provides a human-friendly output as default.Friendly interfaceautocomplete the previous queriescombo box to select the filescolorized syntax highlightingpre-commitCopy themain.pyavailable atpyastrx/.pre-commit-hookin your folder and add the following entry in your.pre-commit-config.yaml.-repo:localhooks:-id:pyastrxname:PyASTrX linterentry:./<LOCATION>/main.pylanguage:scriptargs:["-q"]types:["python"]description:Check for any violations using the pyastrx.yaml config-id:pyastrx-yamlname:PyASTrX linterentry:./<LOCATION>/main.pylanguage:scriptargs:["-q"]types:["yaml"]description:Check for any violations using the pyastrx.yaml configLater on, I will ship this to be used in the pre-commit channels.VsCode extensionSoon, I will ship a VS Code extension.Explore the AST and XMLUsing the :code:-iarg or adding a :code:interactive: truein yourpyastrx.yamlyou can explore the AST and XML parsed AST of your code.
This can be useful to understand your code base and helps you to write
you custom XPATH queries to be used in your project.Folder explorationStart the interactive interface$pyastrx-i-dpath_to_folder(orjustsavethatinyaml)Press f and choose a fileChoose the ast (t), xml (x) or code exploration (o)Learn!File exploration (one key-press distance)Open the interactive with the python file$pyastrx-i-fpath_to_file(orjustsavethatinyaml)Choose the ast (t), xml (x) or code exploration (o)On the shoulders of giantsThis project is possible only because of the work of several
developers across the following projects:lxmlOne of the greatest Python libraries, downloaded over millions of time.
Please, consider doing a donation to thelxmldevelopers.astpathThe PyASTrX started with the idea of using the astpath as a dependency, but I’ve
decided to rewrite and redesign it to improve the maintainability and the
usability features of PyASTrX.astpathis a great and simple tool
developed byH. Chase Stevens.GASTGASTit’s a remarkable tool developed bySerge Sans Paille.
GAST allows you to use the same XPATH expressions to analyze different
code bases written in different python versions.prompt_toolkitA project created byJonathan Slendersthatprovides a powerful and reliable way to construct command-line interfaces.This project has a lot of features, good documentation and the maintainers keep
it well updated.