mirror of https://github.com/astral-sh/ruff
When computing the boolean value of an f-string, we over-eagerly interpreted some f-string interpolations as empty. In this PR we now mark the truthiness of f-strings involving format specs, debug text, and bytes literals as "unknown". This will probably result in some false negatives, which may be further refined (for example - there are probably many cases where `is_not_empty_f_string` should be modified to return `true`), but for now at least we should have fewer false positives. Affected rules (may not be an exhaustive list): - [unnecessary-empty-iterable-within-deque-call (RUF037)](https://docs.astral.sh/ruff/rules/unnecessary-empty-iterable-within-deque-call/#unnecessary-empty-iterable-within-deque-call-ruf037) - [falsy-dict-get-fallback (RUF056)](https://docs.astral.sh/ruff/rules/falsy-dict-get-fallback/#falsy-dict-get-fallback-ruf056) - [pytest-assert-always-false (PT015)](https://docs.astral.sh/ruff/rules/pytest-assert-always-false/#pytest-assert-always-false-pt015) - [expr-or-not-expr (SIM221)](https://docs.astral.sh/ruff/rules/expr-or-not-expr/#expr-or-not-expr-sim221) - [expr-or-true (SIM222)](https://docs.astral.sh/ruff/rules/expr-or-true/#expr-or-true-sim222) - [expr-and-false (SIM223)](https://docs.astral.sh/ruff/rules/expr-and-false/#expr-and-false-sim223) Closes #19935 |
||
|---|---|---|
| .. | ||
| visitor | ||
| comparable.rs | ||
| docstrings.rs | ||
| expression.rs | ||
| generated.rs | ||
| helpers.rs | ||
| identifier.rs | ||
| int.rs | ||
| lib.rs | ||
| name.rs | ||
| node.rs | ||
| node_index.rs | ||
| nodes.rs | ||
| operator_precedence.rs | ||
| parenthesize.rs | ||
| python_version.rs | ||
| relocate.rs | ||
| script.rs | ||
| statement_visitor.rs | ||
| stmt_if.rs | ||
| str.rs | ||
| str_prefix.rs | ||
| traversal.rs | ||
| types.rs | ||
| visitor.rs | ||
| whitespace.rs | ||