From 0726e823423ff1029aeb39797bb1f7714e475c65 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Fri, 10 May 2024 12:10:34 -0700 Subject: [PATCH] [pyflakes] Update docs to describe WAI behavior (F541) (#11362) Addresses this comment: https://github.com/astral-sh/ruff/issues/11357#issuecomment-2104714029 ## Summary The docs for F541 did not mention some surprising, but WAI, behavior regarding implicit string concatenation. Update the docs to describe the behavior. Here's how things rendered for me locally: ![image](https://github.com/astral-sh/ruff/assets/5386897/32067121-b190-4268-b987-ff37df11a618) --- .../rules/f_string_missing_placeholders.rs | 22 +++++++++++++++++++ scripts/check_docs_formatted.py | 1 + 2 files changed, 23 insertions(+) diff --git a/crates/ruff_linter/src/rules/pyflakes/rules/f_string_missing_placeholders.rs b/crates/ruff_linter/src/rules/pyflakes/rules/f_string_missing_placeholders.rs index 36263f3328..122e78d63d 100644 --- a/crates/ruff_linter/src/rules/pyflakes/rules/f_string_missing_placeholders.rs +++ b/crates/ruff_linter/src/rules/pyflakes/rules/f_string_missing_placeholders.rs @@ -29,6 +29,28 @@ use crate::checkers::ast::Checker; /// "Hello, world!" /// ``` /// +/// **Note:** to maintain compatibility with PyFlakes, this rule only flags +/// f-strings that are part of an implicit concatenation if _none_ of the +/// f-string segments contain placeholder expressions. +/// +/// For example: +/// +/// ```python +/// # Will not be flagged. +/// ( +/// f"Hello," +/// f" {name}!" +/// ) +/// +/// # Will be flagged. +/// ( +/// f"Hello," +/// f" World!" +/// ) +/// ``` +/// +/// See [#10885](https://github.com/astral-sh/ruff/issues/10885) for more. +/// /// ## References /// - [PEP 498](https://www.python.org/dev/peps/pep-0498/) #[violation] diff --git a/scripts/check_docs_formatted.py b/scripts/check_docs_formatted.py index 96f6ec3a74..979aee658a 100755 --- a/scripts/check_docs_formatted.py +++ b/scripts/check_docs_formatted.py @@ -39,6 +39,7 @@ KNOWN_FORMATTING_VIOLATIONS = [ "blank-lines-before-nested-definition", "blank-lines-top-level", "explicit-string-concatenation", + "f-string-missing-placeholders", "indent-with-spaces", "indentation-with-invalid-multiple", "line-too-long",