You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Pyflakes] F541 fix changes behavior if the string becomes a docstring #18807
If the string f-string-missing-placeholders (F541) is targeting is in a position where it would become a docstring, it can change behavior. It should probably be marked unsafe or not apply in this case. playground
PS ~\Desktop\New_folder\ruff>Get-Content issue.py
f"Hello, world!"print(__doc__)
PS ~\Desktop\New_folder\ruff>py issue.py
None
PS ~\Desktop\New_folder\ruff>uvx ruff check issue.py --isolated --select F
Hi, how's it going @MichaReiser? I saw that a while ago you said we shouldn't offer a fix here. I'd like to ask for your opinion: I've been running some tests and noticed the scope is wider than what was originally reported; it's not just the module case — I've verified that function, class and implicit concatenation are also affected (""f"" becomes "" ""). I wanted to know whether you'd still prefer the earlier approach (not offering a fix) or degrading it to unsafe? I've already identified where a check could go. Looking forward to your reply, thanks!
Either unsafe or not provide a fix seems fine to me. Yes, this applies to f-strings in all docstring positions, this also includes attribute docstrings
Perfect, thank you! One more question: would you recommend covering only the reachable positions, avoiding touching the checker? Or would you accept a change to cover all of them? With that, I could cover module and attribute. Thanks again!
Activity
MichaReiser commentedon Jun 20, 2025
Thanks. I think we shouldn't provide a fix in this (rare) case
fix(pyflakes): suppress F541 autofix when removal would create a docs…
baltasarblanco commentedon Aug 26, 2026
Hi, how's it going @MichaReiser? I saw that a while ago you said we shouldn't offer a fix here. I'd like to ask for your opinion: I've been running some tests and noticed the scope is wider than what was originally reported; it's not just the module case — I've verified that function, class and implicit concatenation are also affected (
""f""becomes"" ""). I wanted to know whether you'd still prefer the earlier approach (not offering a fix) or degrading it to unsafe? I've already identified where a check could go. Looking forward to your reply, thanks!MichaReiser commentedon Aug 26, 2026
Either unsafe or not provide a fix seems fine to me. Yes, this applies to f-strings in all docstring positions, this also includes attribute docstrings
baltasarblanco commentedon Aug 26, 2026
Perfect, thank you! One more question: would you recommend covering only the reachable positions, avoiding touching the checker? Or would you accept a change to cover all of them? With that, I could cover module and attribute. Thanks again!
[`pyflakes`] Mark the fix as unsafe when it creates a docstring (`F54…