From 66228480c4b88a8944335d49d0b94d5d5f9a99d5 Mon Sep 17 00:00:00 2001 From: Douglas Thor Date: Fri, 10 May 2024 14:51:35 +0000 Subject: [PATCH 1/2] [pyflakes] Update docs to describe WAI behavior (F541) Addresses this comment: https://github.com/astral-sh/ruff/issues/11357#issuecomment-2104714029 --- .../rules/f_string_missing_placeholders.rs | 22 +++++++++++++++++++ 1 file changed, 22 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 36263f332809e..e169bd85d887c 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 regarding implicit string concatenation:** In order to maintain +/// compatibility with the original PyFlakes rule, this rule is only flagged +/// when _none_ of the f-strings in an implicit string concatenation have +/// placeholders. For example: +/// +/// ```python +/// # Will not be flagged +/// ( +/// f"Hello," +/// f" {name}!" +/// ) +/// +/// # Will be flagged +/// ( +/// f"Hello," +/// f" World!" +/// ) +/// ``` +/// +/// See [Issue #10885](https://github.com/astral-sh/ruff/issues/10885) for +/// more information. +/// /// ## References /// - [PEP 498](https://www.python.org/dev/peps/pep-0498/) #[violation] From 2ed81c4c7a6738cccaa66e0521834d56a486805c Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Fri, 10 May 2024 15:03:13 -0400 Subject: [PATCH 2/2] Ignore formatting; tweak structure --- .../rules/f_string_missing_placeholders.rs | 16 ++++++++-------- scripts/check_docs_formatted.py | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) 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 e169bd85d887c..122e78d63d3b8 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,27 +29,27 @@ use crate::checkers::ast::Checker; /// "Hello, world!" /// ``` /// -/// **Note regarding implicit string concatenation:** In order to maintain -/// compatibility with the original PyFlakes rule, this rule is only flagged -/// when _none_ of the f-strings in an implicit string concatenation have -/// placeholders. For example: +/// **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 +/// # Will not be flagged. /// ( /// f"Hello," /// f" {name}!" /// ) /// -/// # Will be flagged +/// # Will be flagged. /// ( /// f"Hello," /// f" World!" /// ) /// ``` /// -/// See [Issue #10885](https://github.com/astral-sh/ruff/issues/10885) for -/// more information. +/// See [#10885](https://github.com/astral-sh/ruff/issues/10885) for more. /// /// ## References /// - [PEP 498](https://www.python.org/dev/peps/pep-0498/) diff --git a/scripts/check_docs_formatted.py b/scripts/check_docs_formatted.py index 96f6ec3a7476a..979aee658a361 100755 --- a/scripts/check_docs_formatted.py +++ b/scripts/check_docs_formatted.py @@ -39,6 +39,7 @@ "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",