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

False positives for some methods of lists for boolean trap rule FBT003 #4382

Closed
namurphy opened this issue May 11, 2023 · 2 comments · Fixed by #4385
Closed

False positives for some methods of lists for boolean trap rule FBT003 #4382

namurphy opened this issue May 11, 2023 · 2 comments · Fixed by #4385

Comments

@namurphy
Copy link

When providing True or False as an argument to the append, count, insert, and remove methods of a list, the rule for catching boolean traps (FBT003) yields false positives even though the arguments are positional-only.

I created file.py which contains:

some_list = []
some_list.append(True)
some_list.count(True)
some_list.insert(0, True)
some_list.remove(True)

Using ruff v0.0.265, I ran:

ruff file.py --select FBT003 --isolated

and got the output:

file.py:2:18: FBT003 Boolean positional value in function call
file.py:3:17: FBT003 Boolean positional value in function call
file.py:4:21: FBT003 Boolean positional value in function call
file.py:5:18: FBT003 Boolean positional value in function call

This follows up on #1336.

Thank you!

@namurphy
Copy link
Author

Wow, that was quick! Thank you for fixing it!

@charliermarsh
Copy link
Member

No prob, it's an easy one :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants