Skip to content

Files

Latest commit

 

History

History
24 lines (16 loc) · 528 Bytes

use-implicit-booleaness-not-comparison.md

File metadata and controls

24 lines (16 loc) · 528 Bytes

Pattern: Missing use of implicit booleaness

Issue: -

Description

Emitted when collection literal comparison is being used to check for emptiness. Use implicit booleaness instead of a collection classes. Empty collections are considered as false.

Example of incorrect code:

if data == {}:
    print("This will be printed")
if data != {}:
    print("This will also be printed")

Example of correct code:

if data or not data:
    print("This however won't be")