Skip to content

rude-dev/rude

Repository files navigation

Rude

License Python versions PyPI version

A fast, extensible Python linter for custom rules.
Complements Ruff by letting you write custom lint rules in Python — with Rust-powered analysis under the hood.
17x faster than Flake8 single-threaded. Custom lint rules in Python, with Rust-powered analysis.

Linting Django (901 files) — 10 equivalent rules, single process
Linting Django (901 files) -- 10 equivalent AST rules, single process


Getting started

# Lints the current workdir
$ uvx rude check

$ uv tool install rude
$ rude --version
rude 0.1a2



# Add rude to your project
uv add rude --dev

Write your first rule

from rude import Rule, Node, NodeType, Diagnostic
from collections.abc import Iterator

class NoDebugPrint(Rule):
    code = "DBG001"
    message = "Debug print() found"
    node_types = {NodeType.CALL}

    def check(self, node: Node) -> Iterator[Diagnostic]:
        if node.function_name == "print":
            yield self.diagnostic(node)

Two base classes: Rule (AST nodes) and LineRule (raw text). Rules can provide autofixes with import management.

Register as a plugin or as local rules:

# pyproject.toml
[project.entry-points."rude.plugins"]
my_plugin = "my_plugin"

[tool.rude]
local-rules = ["tools/linting/rules.py"]

Key features

  • Severity levels -- ERROR breaks CI, WARNING doesn't. Four levels (error, warning, info, hint) per rule, filterable with --quiet.
  • Template rules -- lint without writing Python. Ban calls, require base classes, enforce decorators -- all from pyproject.toml.
  • Autofix with imports -- Fix.replace(node, text, imports_from=[...]) handles insertion, deduplication, and placement automatically.
  • Fast -- Rust-powered tree-sitter parsing and semantic analysis. Streaming pipeline keeps memory flat across a project (buffered when --fix rewrites files); the GIL is released during per-file Rust analysis.
  • Rich Node API -- node.function_name, node.inherits_from("Base"), node.decorator_names. No raw tree-sitter needed.
  • 104 built-in rules -- pyflakes (F), pycodestyle (E/W), McCabe (C901). Additional rule sets can be added via third-party plugins or local Python rule files.

The sweet spot

Standard rules Custom rules Speed Memory Severity
Ruff 800+ none fastest low all fatal
Rude 104 + plugins unlimited fast low 4 levels
Flake8 100+ (plugins) via packages slow medium all fatal
Fixit ~30 via LibCST slow high all fatal

About

No description, website, or topics provided.

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors