Git Product home page Git Product logo

What is PyASTrX?

"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 should walk a mile in someone's shoes before judging the code quality of someone else's code.

PyASTrX allows you to define new code analysis patterns using just XPATH expressions. No need to write an extension to use in flake8 or pylint!

Install

$ pip install pyastrx

Features and Characteristics

PyASTrX provides the following features:

An easy customizable code quality analysis tool.

Type pyastrx -h to see all the options.

You can also use a pyastrx.yaml file to configure the tool.

Human-friendly

Search and Linter outputs

If 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.

Human friendly outputs

Friendly interface

  • autocomplete the previous queries
  • combo box to select the files
  • colorized syntax highlighting

Human friendly outputs

pre-commit

Copy the main.py available at pyastrx/.pre-commit-hook in your folder and add the following entry in your .pre-commit-config.yaml file:

 - repo: local
        hooks:
        - id: pyastrx
            name: PyASTrX linter
            entry: ./<LOCATION>/main.py
            language: script
            args: ["-q"]
            types: ["python"]
            description: Check for any violations using the pyastrx.yaml config

Later on, I will ship this to be used in the pre-commit channels.

VS Code Extension

Soon, I will ship a VS Code extension.

Explore the AST and XML

Using the -i arg or adding a interactive: true in your pyastrx.yaml you can explore the AST and XML parsed AST of your code. This can be useful to understand your code base and help you to write you custom XPATH queries to be used in your project.

Folder and file explorer

Start the interactive interface

$ pyastrx -i -d path_to_folder (or just save that in yaml)

Press f and choose a file

Interactive interface

Choose the ast (t), xml (x) or code exploration (o)

Interactive interface

Learn!

Interactive interface

Interactive interface

File exploration (one key-press distance)

Open the interactive with the python file

$ pyastrx -i -f path_to_file (or just save that in yaml)

*Choose the ast (t), xml (x) or code exploration (o)

Acknowledgments

This project is possible only because of the work of several developers across the following projects:

lxml

One of the greatest Python libraries downloaded over millions of time. Please, consider doing a donation to the lxml developers.

astpath

The 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. astpath is a great and simple tool developed by H. Chase Stevens.

GAST

GAST is a remarkable tool developed by Serge Sans Paille. GAST allows PyASTrX use the same XPATH expressions to analyze different code bases written in different python versions.

prompt_toolkit

A project created by Jonathan Slenders that provides a powerful and reliable way to construct command-line interfaces.

This project has a lot of features, and good documentation and the maintainers keep it well updated.

PyASTrX's Projects

PyASTrX doesnโ€™t have any public repositories yet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.