A fast, feature-rich static code analyzer & language server for Python
Find a file
Shunsuke Shibayama b7e78b310c Update README.md
2025-05-10 11:10:28 +09:00
.cargo Update with dependencies 2023-02-04 10:51:55 +09:00
.github Update bug-report.yaml 2025-02-09 01:35:27 +09:00
.vscode Fix: checking multiple files (#126) 2025-02-24 17:24:27 +09:00
crates build: update version (v0.0.82) 2025-02-25 17:36:36 +09:00
docs feat: add --do-not-respect-pyi option 2025-02-18 22:29:34 +09:00
extension feat: deep completion can be disabled 2025-02-09 12:41:25 +09:00
images doc: update 2024-10-16 16:47:59 +09:00
src Fix: checking multiple files (#126) 2025-02-24 17:24:27 +09:00
tests feat: attrs can be registered in methods other than __init__ 2025-02-22 10:56:21 +09:00
.gitignore fix: misalignment of error display 2024-10-13 18:31:06 +09:00
.pre-commit-config.yaml test: fix stack overflow 2023-02-24 16:12:04 +09:00
Cargo.lock build: update version (v0.0.82) 2025-02-25 17:36:36 +09:00
Cargo.toml build: update version (v0.0.82) 2025-02-25 17:36:36 +09:00
cargo_publish.ps1 Update cargo_publish.ps1 2023-02-24 19:38:37 +09:00
cargo_publish.sh refactor: add pylyzer_core crate 2024-08-20 12:46:27 +09:00
LICENSE initial commit 2022-12-12 22:40:50 +09:00
mkdocs.yml docs: add mkdocs.yml 2023-04-30 22:35:52 +09:00
mkdocs_build.bat docs: add mkdocs.yml 2023-04-30 22:35:52 +09:00
mkdocs_build.sh doc: update docs 2024-08-18 14:22:42 +09:00
publish.sh Create publish.sh 2023-09-18 02:01:33 +09:00
pyproject.toml build: lower minimum version requirements 2023-09-10 17:58:17 +09:00
README.md Update README.md 2025-05-10 11:10:28 +09:00
setup.py feat: Version-independent wheel files 2024-08-11 17:07:50 +09:00

pylyzer

Important

pylyzer is now under the maintenance phase, which means that only bug fixes will be made and no new features will be added. The author is currently cooperating with the development of astral-sh/ty. Please try that instead!

pylyzer_logo_with_letters

vsm-version Build status Build status

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

Installation

pip

pip install pylyzer

cargo (Rust package manager)

cargo install pylyzer --locked

build from source

git clone https://github.com/mtshiba/pylyzer.git
cargo install --path . --locked

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

GitHub Releases

How to use

Check a single file

pylyzer file.py

Check multiple files

# glob patterns are supported
pylyzer file1.py file2.py dir/file*.py

Check an entire package

If you don't specify a file path, pylyzer will automatically search for the entry point.

pylyzer

Start the language server

This option is used when an LSP-aware editor requires arguments to start pylyzer.

pylyzer --server

For other options, check the manual.

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

  • Performance 🌟

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

  • Reports readability 📖

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

pyright

pyright_report

pylyzer 😃

report

  • Rich LSP support 📝

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

You can install the VSCode extension from the Marketplace or from the command line:

code --install-extension pylyzer.pylyzer

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 & formatting, 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

  • pylyzer's type inspector only assumes (potentially) statically typed code, so you cannot check any code uses reflections, such as exec, setattr, etc.

  • pylyzer (= Erg's type system) has its own type declarations for the Python standard APIs. Typing of all APIs is not complete and may result in an error that such an API does not exist.

  • Since pylyzer's type checking is conservative, you may encounter many (possibly false positive) errors. We are working on fixing this, but if you are concerned about editor errors, please turn off the diagnostics feature.

TODOs

  • type checking
    • variable
    • operator
    • function/method
    • class
    • async/await
    • user-defined abstract class
  • type inference
    • variable
    • operator
    • function/method
    • class
  • builtin modules analysis
  • local scripts analysis
  • local packages analysis
  • LSP features
    • diagnostics
    • completion
    • rename
    • hover
    • goto definition
    • signature help
    • find references
    • document symbol
    • call hierarchy
  • collection types
    • list
    • dict
    • tuple
    • set
  • typing
    • Union
    • Optional
    • Literal
    • Callable
    • Any
    • TypeVar
    • TypedDict
    • ClassVar
    • Generic
    • Protocol
    • Final
    • Annotated
    • TypeAlias
    • TypeGuard
    • type parameter syntax
    • type narrowing
    • others
  • collections.abc
    • Collection
    • Container
    • Generator
    • Iterable
    • Iterator
    • Mapping, MutableMapping
    • Sequence, MutableSequence
    • others
  • type assertion (typing.cast)
  • type narrowing (is, isinstance)
  • pyi (stub) files support
  • glob pattern file check
  • type comment (# type: ...)
  • virtual environment support
  • package manager support
    • pip
    • poetry
    • uv

Join us!

We are looking for contributors to help us improve pylyzer. If you are interested in contributing and have any questions, please feel free to contact us.


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.