Skip to content

chore: ruff auto-fix F541 — f-string-missing-placeholders - #42034

Closed
wesleysimplicio wants to merge 1 commit into
NousResearch:mainfrom
wesleysimplicio:chore/ruff-F541
Closed

wesleysimplicio wants to merge 1 commit into
NousResearch:mainfrom
wesleysimplicio:chore/ruff-F541

Conversation

@wesleysimplicio

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds the F541 rule to pyproject.toml and applies auto-fix across 63 files.

Converts f-strings with no placeholder expressions — f"hello""hello" — since they execute the placeholder-expansion machinery for nothing.

Root cause

F-strings without {...} placeholders are syntactically valid but waste a format-call and are invisible bugs waiting to happen: a future editor adding {var} where the f prefix is missing gets a plain string instead of the expected interpolation. Making them an error keeps the codebase consistent.

Fix

  • Added F541 to [tool.ruff.lint] select in pyproject.toml.
  • Ran ruff check --select F541 --preview --fix . — 198 errors fixed across 63 files.

Why this shape

This is the same per-rule pattern used in the existing ruff PRs (#31825#32027): enable one rule, auto-fix, commit. Separating rules keeps the diff focused and the blame history clean.

Tests

  • ruff check passes with zero errors after the fix (rule is active in config).
  • No runtime behaviour changed — only syntactic transformations.
  • Existing pytest suite continues to pass.

Related PRs / issues

  • Part of the ongoing ruff rule enablement campaign.
  • No competing PRs found for F541.

@wesleysimplicio
wesleysimplicio requested a review from a team June 8, 2026 11:08
@alt-glitch alt-glitch added type/refactor Code restructuring, no behavior change P3 Low — cosmetic, nice to have labels Jun 8, 2026
@Morad37

Morad37 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Clean auto-fix pass. The f\"...\" strings without placeholders are a common lint catch after refactors where a variable was inlined or removed. The F541 rule exists precisely for this -- saves readers a second of "wait, is there a substitution I'm missing?" on every read.

@austinpickett

Copy link
Copy Markdown
Collaborator

See consolidation note on #42036 — these four ruff PRs overlap and should be combined into one before merging.

@wesleysimplicio

Copy link
Copy Markdown
Contributor Author

Closing in favor of consolidated PR (per austinpickett's request on #42036 — combining all four ruff PRs into one.)

@wesleysimplicio
wesleysimplicio deleted the chore/ruff-F541 branch June 12, 2026 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low — cosmetic, nice to have type/refactor Code restructuring, no behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants