Coder Social home page Coder Social logo

iq-scm / pylyzer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mtshiba/pylyzer

0.0 0.0 0.0 2.57 MB

A fast static code analyzer & language server for Python

Home Page: http://mtshiba.me/pylyzer/

License: MIT License

Shell 0.55% JavaScript 1.14% Python 4.03% Rust 89.64% PowerShell 0.54% TypeScript 4.08% Batchfile 0.02%

pylyzer's Introduction

pylyzer โšก

pylyzer_logo_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)

cargo install pylyzer

pip

pip install pylyzer

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

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

GitHub Releases

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

  • Detailed analysis ๐Ÿฉบ

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

  • Reports readability ๐Ÿ“–

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

pylyzer ๐Ÿ˜ƒ

report

pyright ๐Ÿ™ƒ

pyright_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

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

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

TODOs

  • type checking
    • variable
    • operator
    • function/method
    • class
  • type inference
    • variable
    • operator
    • function/method
    • class
  • builtin modules resolving (partially)
  • local scripts resolving
  • local packages resolving
  • collection types
    • list
    • dict
    • tuple
  • typing
    • Union
    • Optional
    • Literal
    • Callable
    • TypedDict
    • type variable (TypeVar, Generic)
    • Protocol
    • Final
    • Annotated
    • TypeAlias
    • type guard (TypeGuard)
    • others
  • collections.abc
    • Iterable
    • Iterator
    • Mapping
    • Sequence
    • others
  • type assertion (typing.cast)
  • type narrowing (is, isinstance)

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.โ†ฉ

pylyzer's People

Contributors

mtshiba avatar

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.