Skip to content

SIM118 should detect not in as well #5989

@dosisod

Description

@dosisod

Last issue for now!

Ruff only detects in, but it should detect not in as well:

d = {}

if "key" in d.keys():
    pass

if "key" not in d.keys():
    pass

Ruff output:

$ ruff x.py
x.py:3:4: SIM118 [*] Use `"key" in d` instead of `"key" in d.keys()`

Expected:

x.py:3:4: SIM118 [*] Use `"key" in d` instead of `"key" in d.keys()`
x.py:6:4: SIM118 [*] Use `"key" not in d` instead of `"key" not in d.keys()`

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedReady for implementationbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions