Skip to content

Simplify key in dct and dct[key] to dct.get(key) #5933

@janosh

Description

@janosh
# bad
if "key" in dct and dct["key"]:
    ...

# good
if dct.get("key"):
    ...

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