We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Imagine this scenario:
class X: def keys(self): return [1, 2, 3] x = X() if 1 in x.keys(): print('yes')
If I run the linter, I get:
SIM118 Use 1 in x instead of 1 in x.keys()
1 in x
1 in x.keys()
Which will obviously lead to a crash. I know that I wouldn't name a method keys() but still I think the rule might cause some problems.
keys()
We need some check that it's really a dict if we want to auto-remove the keys...
We might crash somebodys code when somebody is auto-fixing it (via ruff) or just blindly following the linter.
The text was updated successfully, but these errors were encountered:
Hi, this actually crashed our code yesterday. Please try to to this only for objects that act like dicts. Maybe something in here can help to identify these structures? https://docs.python.org/3/reference/datamodel.html?emulating-container-types=#emulating-container-types
Sorry, something went wrong.
MartinThoma
No branches or pull requests
Example
Imagine this scenario:
If I run the linter, I get:
Which will obviously lead to a crash. I know that I wouldn't name a method
keys()
but still I think the rule might cause some problems.We need some check that it's really a dict if we want to auto-remove the keys...
Explanation
We might crash somebodys code when somebody is auto-fixing it (via ruff) or just blindly following the linter.
The text was updated successfully, but these errors were encountered: