Skip to main content

Rattle

Tests Documentation Status PyPI version Supported versions Downloads License: MIT

Rattle is a Python linting framework built on LibCST with support for autofixes, custom in-repo lint rules, and hierarchical configuration.

Rattle is a fork of Fixit.

Features

  • 48 built-in lint rules
  • Autofix support when a rule can safely rewrite code
  • Local custom rules that can live inside your repository
  • Hierarchical pyproject.toml configuration
  • Pre-commit integration for CI and local workflows
  • LSP support

Install

From PyPI

uv tool install rattle-lint
pip install rattle-lint

With editor/LSP support

uv tool install "rattle-lint[lsp]"
pip install "rattle-lint[lsp]"

Agent Skill

The official AI agent skill can be installed from this repo.

npx skills add https://github.com/zigai/rattle/tree/main/src/rattle/.agents/skills/create-rattle-lint-rules

or

uvx library-skills

Basic Usage

Rattle enables no rules by default. A practical baseline for a typical typed Python project is:

[tool.rattle]
root = true
enable = [
    "blank-line-after-control-block",
    "blank-line-after-terminal-control-block",
    "blank-line-before-branch",
    "blank-line-before-unrelated-block",
    "no-suite-leading-trailing-blank-lines",
    "module-all-at-bottom",
    "no-underscore-all-exports",
    "forbidden-call",
    "no-relative-imports",
    "no-underscore-import-aliases",
    "no-unsafe-tempfile-factories",
    "no-annotated-self",
    "no-exception-message-variables",
    "no-str-exception-translation",
    "no-underscore-class",
    "public-method-order",
    "no-bare-object-annotations",
    "no-named-tuple",
    "no-static-if-condition",
    "sorted-attributes",
    "use-callable-ellipsis",
]

[tool.rattle.options."forbidden-call"]
forbidden_calls = ["typing.cast"]

Adjust the list to match the project, then lint the repository:

rattle lint .

Apply available autofixes:

rattle fix .

Explain rule metadata, examples, and settings:

rattle explain no-bare-object-annotations
rattle explain --json no-bare-object-annotations

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rattle_lint-2.7.1.tar.gz (331.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rattle_lint-2.7.1-py3-none-any.whl (250.0 kB view details)

Uploaded Python 3

File details

Details for the file rattle_lint-2.7.1.tar.gz.

File metadata

  • Download URL: rattle_lint-2.7.1.tar.gz
  • Upload date:
  • Size: 331.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for rattle_lint-2.7.1.tar.gz
Algorithm Hash digest
SHA256 5d4538062d4544221166eaf36de89f3b7971af5f6d13ff7597b78f594d79e664
MD5 fe36ad498a3276bd80708100b5fb9a87
BLAKE2b-256 93cf66440629c61a9c885e34f6d7b44c4c8909a68f381dc16b72953b290c3dc0

See more details on using hashes here.

File details

Details for the file rattle_lint-2.7.1-py3-none-any.whl.

File metadata

  • Download URL: rattle_lint-2.7.1-py3-none-any.whl
  • Upload date:
  • Size: 250.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.10.20

File hashes

Hashes for rattle_lint-2.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6d2d4693baa61cebca2bcb7331d8c4557623c345fd3b06215274340e6e039133
MD5 fb603fe12a7a0cd6a1810d8c82034a69
BLAKE2b-256 3d117b1e4b6eece24e1ee9b2f41b8cc603044f6f98d047f1a729f9c7111b82bf

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page