Skip to main content

'Simple projects are all alike; each complexproject is complex in its own way.' - (adapted from Tolstoy's Anna Karenina)

Project description

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 should walk a **mile in **someone’s shoes** 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!

pip install pyastrx

Features

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.

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

VsCode extension

Soon, I will ship a VS Code extension.

Explore the AST and XML

Using the :code: -i arg or adding a :code: 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 helps you to write you custom XPATH queries to be used in your project.

Folder exploration

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)

On the shoulders of giants

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 it’s a remarkable tool developed by Serge Sans Paille. GAST allows you to 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, good documentation and the maintainers keep it well updated.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyastrx-0.1.0.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyastrx-0.1.0-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

File details

Details for the file pyastrx-0.1.0.tar.gz.

File metadata

  • Download URL: pyastrx-0.1.0.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for pyastrx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f3ebbef37dcb76e5326659fd1b72615b9c7a14603c54a1058bb819608574d362
MD5 6682e1dc51f50743b3481183522b8bff
BLAKE2b-256 40dbb356eb9672450df0f9eca60efda8bdc7dcaa3d00c674bfa9f8fd4d37e900

See more details on using hashes here.

File details

Details for the file pyastrx-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pyastrx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 24.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for pyastrx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a0548957886990c6d1fd32a4e2996b352b95c2f0d4fb7f752a57e2588b7da07f
MD5 b615ba33a3d8e504362d044d75206ca9
BLAKE2b-256 b53ecf83ff67970aa4eb35e605e29830099dc0549152ba023dd1308c2f97e749

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page