Skip to content

Remove falsy dict.get() fallback in if statements #4934

@janosh

Description

@janosh
# bad
if dct.get(key, False):
if dct.get(key, ""):
if dct.get(key, []):
if dct.get(key, {}):

# good
if dct.get(key):

# bad
if dct.get(key, set()) and other_cond:
if dct.get(key, 0) or other_cond:

# good
if dct.get(key) and other_cond:
if dct.get(key) or other_cond:

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedReady for implementationruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions