Skip to content

Conversation

@pieterh-oai
Copy link
Contributor

@pieterh-oai pieterh-oai commented Oct 9, 2025

Summary

The original autofix for G004 was quietly dropping everything but the f-string components of any implicit concatenation sequence; this addresses that.

Side note: It looks like f_strings is a bit risky to use (since it implicitly skips non-f-string parts); use iter and include implicitly concatenated pieces. We should consider if it's worth having (convenience vs. bit risky).

Test Plan

cargo test -p ruff_linter

Backtest (run new testcases against previous implementation):

git checkout HEAD^ crates/ruff_linter/src/rules/flake8_logging_format/rules/logging_call.rs
cargo test -p ruff_linter

Test:

```
cargo test -p ruff_linter
```

Backtest (run new testcases against previous implementation):
```
git checkout HEAD^ crates/ruff_linter/src/rules/flake8_logging_format/rules/logging_call.rs
cargot test -p ruff_linter

```
@github-actions
Copy link
Contributor

github-actions bot commented Oct 9, 2025

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

@ntBre ntBre added bug Something isn't working fixes Related to suggested fixes for violations preview Related to preview mode features labels Oct 9, 2025
Copy link
Contributor

@ntBre ntBre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, thank you!

Yeah, f_strings does seem a bit risky to use, I certainly didn't realize this when reviewing the fix initially. I quickly went through the other references, and they look correct at least.

It also seems a bit unfortunate that we join the implicitly concatenated parts, but we could follow up on that separately.

@ntBre ntBre changed the title [ruff_linter][G004 autofix] drops implicit concat pieces in the format string -> fix [flake8-logging-format] Avoid dropping implicitly concatenated pieces in the G004 fix Oct 9, 2025
@ntBre ntBre merged commit 66885e4 into astral-sh:main Oct 9, 2025
39 checks passed
@pieterh-oai
Copy link
Contributor Author

Thanks for the quick review @ntBre !

@pieterh-oai pieterh-oai deleted the pieterh-oai/G004-implicit-concat branch October 28, 2025 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fixes Related to suggested fixes for violations preview Related to preview mode features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants