wemake-python-styleguide icon indicating copy to clipboard operation
wemake-python-styleguide copied to clipboard

Report redundant str() and repr() for str.format args

Open orsinium opened this issue 4 years ago • 0 comments

Rule request

Thesis

For most of the objects (for all objects and builtins, until redefined explicitly), the default result of __format__ is the same as __str__, so wrapping arguments of str.format into str() or repr() is redundant.

# bad
'{}'.format(str(1))

# good
'{}'.format(1)

# bad
'{}'.format(repr('a'))

# good
'{!r}'.format('a')

Reasoning

Simplification.

orsinium avatar Feb 26 '21 08:02 orsinium