Skip to content

consider-using-augmented-assign false positive on string formatting #8179

@jolaf

Description

@jolaf

Bug description

s = "text %s"
s = s % 5

Formally, the warning is acceptable, as %= construct indeed can be used in this situation.

But from my point of view using s %= 5 in this context would look weird, be misleading and should not be recommended.

So my proposition is to turn off this checker for % operation where the left operand is str or bytes.

Command used

pylint test.py

Pylint output

************* Module test
test.py:2: [R6104(consider-using-augmented-assign), ] Use '%=' to do an augmented assign directly

Expected behavior

no output

Pylint version

pylint 2.16.1
astroid 2.14.1
Python 3.10.6 (main, Nov 14 2022, 16:10:14) [GCC 11.3.0]

OS / Environment

Ubuntu 22.04.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions