pylyzer ⚡

pylyzer<em>logo</em>with_letters

vsm-version Build status Build status

pylyzer is a static code analyzer / language server for Python, written in Rust.

Installation

cargo (rust package manager)

bash cargo install pylyzer

Make sure that cargo/rustc is up-to-date, as pylyzer may be written with the latest language features.

pip

bash pip install pylyzer

If installed this way, you also need to install Erg.

bash curl -L https://github.com/mtshiba/ergup/raw/main/ergup.py | python3

GitHub Releases

What is the advantage over pylint, pyright, pytype, etc.?

On average, pylyzer can inspect Python scripts more than 100 times faster than pytype and pyright 1. This is largely due to the fact that pylyzer is implemented in Rust.

performance

pylyzer can do more than the type checking. For example, it can detect out-of-bounds accesses to lists and accesses to nonexistent keys in dicts.

analysis

While pytype/pyright's error reports are illegible, pylyzer shows where the error occurred and provides clear error messages.

pylyzer 😃

report

pyright 🙃

pyright_report

pylyzer as a language server supports various features, such as completion and renaming (The language server is an adaptation of the Erg Language Server (ELS). For more information on the implemented features, please see here).

lsp_support

autoimport

VSCode extension

What is the difference from Ruff?

Ruff, like pylyzer, is a static code analysis tool for Python written in Rust, but Ruff is a linter and pylyzer is a type checker & language server. pylyzer does not perform linting, and Ruff does not perform type checking.

How it works

pylyzer uses the type checker of the Erg programming language internally. This language is a transpiled language that targets Python, and has a static type system.

pylyzer converts Python ASTs to Erg ASTs and passes them to Erg's type checker. It then displays the results with appropriate modifications.

Limitations

TODOs


1 The performance test was conducted on MacBook (Early 2016) with 1.1 GHz Intel Core m3 processor and 8 GB 1867 MHz LPDDR3 memory.