Skip to content

Commit

Permalink
Enable Maturin (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Charlie Marsh authored Aug 10, 2022
1 parent d6b4623 commit 36efdfe
Show file tree
Hide file tree
Showing 5 changed files with 221 additions and 11 deletions.
168 changes: 165 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# Local cache
.cache

# IntelliJ
.idea

###
# Rust.gitignore
###
Expand All @@ -22,3 +19,168 @@ Cargo.lock

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

###
# Python.gitignore
###

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name = "rust-python-linter"
version = "0.1.0"
edition = "2021"

[lib]
name = "rust_python_linter"
crate-type = ["cdylib", "lib"]

[dependencies]
anyhow = { version = "1.0.60" }
bincode = { version = "1.3.3" }
Expand All @@ -19,3 +23,4 @@ rustpython-parser = { git = "https://github.com/RustPython/RustPython.git", rev
serde = { version = "1.0.143", features = ["derive"] }
serde_json = { version = "1.0.83" }
walkdir = { version = "2.3.2" }
pyo3 = { version = "0.16.5", features = ["extension-module", "abi3-py37"] }
50 changes: 45 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,56 @@
# rust-python-linter

A [Pyflakes](https://github.com/PyCQA/pyflakes)-inspired Python linter, written in Rust.
A performance-focused, [Pyflakes](https://github.com/PyCQA/pyflakes)-inspired Python linter, written
in Rust.

Supports:
Features:

- Python 3.10
- True parallelism
- Python 3.10 compatibility
- [ESLint](https://eslint.org/docs/latest/user-guide/command-line-interface#caching)-inspired
caching
cache semantics
- [TypeScript](https://www.typescriptlang.org/docs/handbook/configuring-watch.html)
-inspired `--watch` semantics

## Installation

Available as [`rust-python-linter`](https://pypi.org/project/rust-python-linter/) on PyPI:

```shell
pip install rust-python-linter
```

## Usage

To run the linter, try any of the following:

```shell
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.:

```shell
rust_python_linter path/to/code/ --watch
```

## Development

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

```shell
cargo fmt
cargo clippy
cargo run resources/test/src
```

## Deployment

`rust-python-linter` is released for Python using [`maturin`](https://github.com/PyO3/maturin):

```shell
maturin publish
```
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["maturin>=0.13,<0.14"]
build-backend = "maturin"
6 changes: 3 additions & 3 deletions src/bin/main.rs → src/bin/rust_python_linter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ use std::path::PathBuf;
use std::sync::mpsc::channel;
use std::time::{Duration, Instant};

use ::rust_python_linter::fs::collect_python_files;
use ::rust_python_linter::linter::check_path;
use ::rust_python_linter::message::Message;
use anyhow::Result;
use clap::{Parser, ValueHint};
use log::{debug, error};
use notify::{watcher, RecursiveMode, Watcher};
use rayon::prelude::*;
use rust_python_linter::fs::collect_python_files;
use rust_python_linter::linter::check_path;
use rust_python_linter::message::Message;
use walkdir::DirEntry;

#[derive(Debug, Parser)]
Expand Down

0 comments on commit 36efdfe

Please sign in to comment.