未提供项目描述
项目描述
rust-python-linter
一个以性能为中心的,受Pyflakes启发的Python代码检查工具,用Rust编写。
特性
- Python 3.10 兼容性
- 受ESLint启发的缓存语义
- 受TypeScript启发的
--watch
语义 - 支持
pyproject.toml
安装
在PyPI上作为rust-python-linter
提供
pip install rust-python-linter
用法
要运行代码检查工具,可以尝试以下任何一种方法
rust_python_linter path/to/code/to/check.py
# ...or...
rust_python_linter path/to/code/
# ...or...
rust_python_linter path/to/code/*.py
也可以以--watch
模式运行,以便在更改时自动重新运行代码检查工具,例如
rust_python_linter path/to/code/ --watch
开发
正如其名,rust-python-linter
是用Rust实现的
cargo fmt
cargo clippy
cargo run resources/test/src
部署
rust-python-linter
使用maturin
发布给Python
maturin publish --skip-existing --target x86_64-apple-darwin
maturin publish --skip-existing --target aarch64-apple-darwin
基准测试
首先,克隆CPython。它是一个庞大且多样化的Python代码库,因此是一个很好的基准测试目标。注意,我们克隆了v3.9,因为RustPython尚未支持在v3.10中引入的模式匹配。
git clone --branch 3.9 https://github.com/python/cpython.git resources/test/cpython
将此pyproject.toml
添加到目录中
[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",
]
接下来,基准测试发布版本
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
项目详情
下载文件
下载适用于您的平台的文件。如果您不确定要选择哪个,请了解更多关于安装包的信息。
源分布
rust_python_linter-0.0.12.tar.gz (35.0 kB 查看哈希值)
构建分布
关闭
哈希值 for rust_python_linter-0.0.12-cp38-cp38-macosx_11_0_arm64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 8d83f81e916404287bf18a1401a4839bd9b2472695effa112300d237d3c827f2 |
|
MD5 | 39911b740006417798e30033df5d3c73 |
|
BLAKE2b-256 | 182570bfca12ead93aa36420b5b6f549fcad67a1d8ddc8038500aa2b3a92e4bf |
关闭
哈希值 for rust_python_linter-0.0.12-cp38-cp38-macosx_10_7_x86_64.whl
算法 | 哈希摘要 | |
---|---|---|
SHA256 | 065fdc1b55fb8a9b51a777c7ab2b804be178cc50ae1bdd31aad0b82eb82075df |
|
MD5 | 80b0a99d3372e124daeccc98191abee3 |
|
BLAKE2b-256 | 6bc7354ae6d6273ab47732024e372e75d3dae1a2b345977d8fa11f594e3a82ed |