PyCQA / flake8-bugbear

A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

B028 should suggest underlying functions instead of obscure flags

kalekseev opened this issue · comments

B028 introduced in #319 should suggest repr instead of !r for readability, these flags were preserved in f-string only for backward compatibility with .format(), from PEP 498 !s, !r, and !a are redundant

Overall, I believe B028 in current form is more harmful than useful, using repr to wrap in quotes is a hack that is unreadable and unreliable #329.
The repr only used because of the lack of specific functions in stdlib, something like textwrap.single_quotes() and textwrap.double_quotes().

Hmm, I actually find this somewhat convincing. @Zac-HD have you considered repr() instead of !r?

@kalekseev the original reasoning behind the flag is #319 to handle quotes inside strings. Though given the number of opened issues it does seem like it should be turned into an optional warning or require several other changes.

Per #331 (comment), let's disable it by default.