use-implicit-booleaness-not-len / C1802ΒΆ

Message emitted:

Do not use `len(SEQUENCE)` without comparison to determine if a sequence is empty

Description:

Empty sequences are considered false in a boolean context. You can either remove the call to 'len' (``if not x``) or compare the length against a scalar (``if len(x) > 1``).

Problematic code:

fruits = ["orange", "apple"]

if len(fruits):  # [use-implicit-booleaness-not-len]
    print(fruits)

Correct code:

fruits = ["orange", "apple"]

if fruits:
    print(fruits)

Created by the refactoring checker.