ruff
694e7ed5 - Less confidently mark f-strings as empty when inferring truthiness (#20152)

Commit
16 days ago
Less confidently mark f-strings as empty when inferring truthiness (#20152) 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
Author
Parents
Loading