Former Spring Discovery and Khan Academy staff engineer Charlie Marsh recently released the latest version of ‘Ruff’, a fast Python linter written in Rust.
Ruff can support over 200 lint rules and is now being used in big open-source projects such as FastAPI, Bokeh, Zulip, and Pydantic.
In comparison to Flake8, Ruff is approximately 150 times faster on macOS, 75 times faster than pycodestyle, and 50 times faster than pyflakes and pylint, among others.
The difference between receiving real-time feedback (roughly 300 and 500 milliseconds) and waiting for 12 or more seconds is 25 times, at least. With a 150-times speed increase, the difference becomes a mere 300–500 milliseconds compared to 75 seconds. Ruff’s total processing time for a single file in CPython is about 60 milliseconds, making it faster.
Ruff employs RustPython’s AST parser and implements its own AST traversal, visitor abstraction, and lint-rule logic. In addition, it supports Python 3.10, consisting of the new pattern-matching syntax.
Ruff can be installed through pip, like other command-line tools.
Like ESLint, Ruff enables caching, allowing single-file code linting and CPython codebase linting in 60 ms. Ruff also includes file watching similar to TypeScript, making it a persistent linter that restarts when the source code is altered. Ruff supports pyproject.toml-based setup, which is becoming more popular in the Python community.
Advertisement
Order the latest Book by Dinesh Pundri
[Update: 16 February 2023 15:32 | Previously, the headline erroneously mentioned that Ruff is a programming language instead of Python Linter. The headline has now been updated to reflect the changes.]