Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIM118 should detect not in as well #5989

Closed
dosisod opened this issue Jul 22, 2023 · 0 comments · Fixed by #5995
Closed

SIM118 should detect not in as well #5989

dosisod opened this issue Jul 22, 2023 · 0 comments · Fixed by #5995
Labels
accepted Ready for implementation bug Something isn't working

Comments

@dosisod
Copy link
Contributor

dosisod commented Jul 22, 2023

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()`
@charliermarsh charliermarsh added bug Something isn't working accepted Ready for implementation labels Jul 23, 2023
sbrugman added a commit to sbrugman/ruff that referenced this issue Jul 23, 2023
sbrugman added a commit to sbrugman/ruff that referenced this issue Jul 23, 2023
sbrugman added a commit to sbrugman/ruff that referenced this issue Jul 23, 2023
charliermarsh pushed a commit that referenced this issue Jul 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants