From 8c80bfa7daa2bbd451a6233d1a3f71e6ea5bdc94 Mon Sep 17 00:00:00 2001 From: rembridge <35376887+arembridge@users.noreply.github.com> Date: Wed, 26 Jul 2023 00:14:43 +0100 Subject: [PATCH] tab indentation comment (#6079) ## Summary Updated doc comment for `tab_indentation.rs`. Online docs also benefit from this update. ## Test Plan Checked docs via [mkdocs](https://github.com/astral-sh/ruff/blob/389fe13c934fe73679474006412b1eded4a2cad0/CONTRIBUTING.md?plain=1#L267-L296) --- .../pycodestyle/rules/tab_indentation.rs | 20 +++++++++++++++++++ scripts/check_docs_formatted.py | 1 + 2 files changed, 21 insertions(+) diff --git a/crates/ruff/src/rules/pycodestyle/rules/tab_indentation.rs b/crates/ruff/src/rules/pycodestyle/rules/tab_indentation.rs index f09219c992..3070d1599c 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/tab_indentation.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/tab_indentation.rs @@ -5,6 +5,26 @@ use ruff_macros::{derive_message_formats, violation}; use ruff_python_ast::source_code::Indexer; use ruff_python_trivia::{leading_indentation, Line}; +/// ## What it does +/// Checks for indentation that uses tabs. +/// +/// ## Why is this bad? +/// According to [PEP 8], spaces are preferred over tabs (unless used to remain +/// consistent with code that is already indented with tabs). +/// +/// ## Example +/// ```python +/// if True: +/// a = 1 +/// ``` +/// +/// Use instead: +/// ```python +/// if True: +/// a = 1 +/// ``` +/// +/// [PEP 8]: https://peps.python.org/pep-0008/#tabs-or-spaces #[violation] pub struct TabIndentation; diff --git a/scripts/check_docs_formatted.py b/scripts/check_docs_formatted.py index f10e38cb0e..408158030b 100755 --- a/scripts/check_docs_formatted.py +++ b/scripts/check_docs_formatted.py @@ -55,6 +55,7 @@ KNOWN_FORMATTING_VIOLATIONS = [ "prohibited-trailing-comma", "shebang-leading-whitespace", "surrounding-whitespace", + "tab-indentation", "too-few-spaces-before-inline-comment", "trailing-comma-on-bare-tuple", "triple-single-quotes",