wemake-python-styleguide
wemake-python-styleguide copied to clipboard
Report redundant str() and repr() for str.format args
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.