Skip to content

Suggested change for use-implicit-booleaness-not-comparison doesn't seem right #9353

@clavedeluna

Description

@clavedeluna

Bug description

z = []
res = z != []

Configuration

enable=use-implicit-booleaness-not-comparison

Command used

pylint test.py

Pylint output

test.py:2:6: C1803: "z != []" can be simplified to "z", if it is strictly a sequence, as an empty list is falsey (use-implicit-booleaness-not-comparison)

Expected behavior

While in an if statement if z != []: pass The suggestion is right, in an assignment context I don't think it is. Changing
res = z != [] to res = z is not the same thing

Pylint version

pylint 3.0.0

OS / Environment

No response

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Enhancement ✨Improvement to a componentNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions