Skip to main content

rust-python-linter

A performance-focused, Pyflakes-inspired Python linter, written in Rust.

Features:

  • Python 3.10 compatibility
  • ESLint-inspired cache semantics
  • TypeScript-inspired --watch semantics
  • pyproject.toml support

Installation

Available as rust-python-linter on PyPI:

pip install rust-python-linter

Usage

To run the linter, try any of the following:

rust_python_linter path/to/code/to/check.py
# ...or...
rust_python_linter path/to/code/
# ...or...
rust_python_linter path/to/code/*.py

You can also run in --watch mode to automatically re-run the linter on-change with, e.g.:

rust_python_linter path/to/code/ --watch

Development

As the name suggests, rust-python-linter is implemented in Rust:

cargo fmt
cargo clippy
cargo run resources/test/src

Deployment

rust-python-linter is released for Python using maturin:

maturin publish --skip-existing --target x86_64-apple-darwin
maturin publish --skip-existing --target aarch64-apple-darwin

Benchmarking

First, clone CPython. It's a large and diverse Python codebase, which makes it a good target for benchmarking. Note that we clone v3.9, as RustPython doesn't yet support pattern matching, which was introduced in v3.10.

git clone --branch 3.9 https://github.com/python/cpython.git resources/test/cpython

Add this pyproject.toml to the directory:

[tool.linter]
line-length = 88
exclude = [
    "Lib/ctypes/test/test_numbers.py",
    "Lib/dataclasses.py",
    "Lib/lib2to3/tests/data/bom.py",
    "Lib/lib2to3/tests/data/crlf.py",
    "Lib/lib2to3/tests/data/different_encoding.py",
    "Lib/lib2to3/tests/data/false_encoding.py",
    "Lib/lib2to3/tests/data/py2_test_grammar.py",
    "Lib/sqlite3/test/factory.py",
    "Lib/sqlite3/test/hooks.py",
    "Lib/sqlite3/test/regression.py",
    "Lib/sqlite3/test/transactions.py",
    "Lib/sqlite3/test/types.py",
    "Lib/test/bad_coding2.py",
    "Lib/test/badsyntax_3131.py",
    "Lib/test/badsyntax_pep3120.py",
    "Lib/test/encoded_modules/module_iso_8859_1.py",
    "Lib/test/encoded_modules/module_koi8_r.py",
    "Lib/test/sortperf.py",
    "Lib/test/test_email/torture_test.py",
    "Lib/test/test_fstring.py",
    "Lib/test/test_genericpath.py",
    "Lib/test/test_getopt.py",
    "Lib/test/test_htmlparser.py",
    "Lib/test/test_importlib/stubs.py",
    "Lib/test/test_importlib/test_files.py",
    "Lib/test/test_importlib/test_metadata_api.py",
    "Lib/test/test_importlib/test_open.py",
    "Lib/test/test_importlib/test_util.py",
    "Lib/test/test_named_expressions.py",
    "Lib/test/test_peg_generator/__main__.py",
    "Lib/test/test_pipes.py",
    "Lib/test/test_source_encoding.py",
    "Lib/test/test_weakref.py",
    "Lib/test/test_webbrowser.py",
    "Lib/tkinter/__main__.py",
    "Lib/tkinter/test/test_tkinter/test_variables.py",
    "Modules/_decimal/libmpdec/literature/fnt.py",
    "Modules/_decimal/tests/deccheck.py",
    "Tools/i18n/pygettext.py",
    "Tools/test2to3/maintest.py",
    "Tools/test2to3/setup.py",
    "Tools/test2to3/test/test_foo.py",
    "Tools/test2to3/test2to3/hello.py",
]

Next, to benchmark the release build:

cargo build --release

hyperfine --warmup 5 \
  "./target/release/rust_python_linter ./resources/test/cpython/ --no-cache" \
  "./target/release/rust_python_linter ./resources/test/cpython/"

Benchmark 1: ./target/release/rust_python_linter ./resources/test/cpython/ --no-cache
  Time (mean ± σ):     353.6 ms ±   7.6 ms    [User: 2868.8 ms, System: 171.5 ms]
  Range (min … max):   344.4 ms … 367.3 ms    10 runs

Benchmark 2: ./target/release/rust_python_linter ./resources/test/cpython/
  Time (mean ± σ):      59.6 ms ±   2.5 ms    [User: 36.4 ms, System: 345.6 ms]
  Range (min … max):    55.9 ms …  67.0 ms    48 runs

Metadata

Release files for rust-python-linter 0.0.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rust-python-linter 0.0.12
File Size Uploaded Provenance Actions
rust_python_linter-0.0.12.tar.gz 35.0 kB Without provenance Details for rust_python_linter-0.0.12.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for rust-python-linter 0.0.12
File Interpreter ABI Platform Actions
rust_python_linter-0.0.12-cp38-cp38-macosx_11_0_arm64.whl CPython 3.8 CPython 3.8 macOS 11.0+ ARM64 Details for rust_python_linter-0.0.12-cp38-cp38-macosx_11_0_arm64.whl
rust_python_linter-0.0.12-cp38-cp38-macosx_10_7_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.7+ x86-64 Details for rust_python_linter-0.0.12-cp38-cp38-macosx_10_7_x86_64.whl

Total release size: 3.2 MB

Release files / rust_python_linter-0.0.12.tar.gz

Download URL rust_python_linter-0.0.12.tar.gz
Size 35.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f32a0b6f237c4d0832d4ed6e47a704819617c48798c1f09fc74c71bfc90e17e4
BLAKE2b-256 checksum
How to use checksums
39cfd6b55e7239a35e7ea117a2d5c37c144a9203b06a7f1fee7db3db9daa735f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.13.0

Release files / rust_python_linter-0.0.12-cp38-cp38-macosx_11_0_arm64.whl

Download URL rust_python_linter-0.0.12-cp38-cp38-macosx_11_0_arm64.whl
Size 1.5 MB
Tags CPython 3.8 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
8d83f81e916404287bf18a1401a4839bd9b2472695effa112300d237d3c827f2
BLAKE2b-256 checksum
How to use checksums
182570bfca12ead93aa36420b5b6f549fcad67a1d8ddc8038500aa2b3a92e4bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.13.0

Release files / rust_python_linter-0.0.12-cp38-cp38-macosx_10_7_x86_64.whl

Download URL rust_python_linter-0.0.12-cp38-cp38-macosx_10_7_x86_64.whl
Size 1.6 MB
Tags CPython 3.8 macOS 10.7+ x86-64
SHA-256 checksum
How to use checksums
065fdc1b55fb8a9b51a777c7ab2b804be178cc50ae1bdd31aad0b82eb82075df
BLAKE2b-256 checksum
How to use checksums
6bc7354ae6d6273ab47732024e372e75d3dae1a2b345977d8fa11f594e3a82ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/0.13.0

Security for rust-python-linter 0.0.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page