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

New flake8-bugbear check B034: count/maxsplit/flag should be passed as keyword parameters #5682

Closed
jakkdl opened this issue Jul 11, 2023 · 2 comments

Comments

@jakkdl
Copy link

jakkdl commented Jul 11, 2023

I added a new check to flake8-bugbear, and it would be great to have it incorporated into ruff as well. Copying from the issue PyCQA/flake8-bugbear#397

Context

Example code

$ re.sub('a', 'b', 'aaa')
'bbb'
$ re.sub('a', 'b', 'aaa', re.IGNORECASE)
'bba'
>>> re.split(' ', 'a a a a')
['a', 'a', 'a', 'a']
>>> re.split(' ', 'a a a a', re.I)
['a', 'a', 'a a']
>>> re.split(' ', 'a a a a', flags=re.I)
['a', 'a', 'a', 'a']

The fourth parameter to re.sub[n] is in fact count, and the third to split is maxsplit, and as seen in the above linked issues this is a very common mistake.

Links

See the issue PyCQA/flake8-bugbear#397 for discussion around implementation, and PyCQA/flake8-bugbear#398 for the PR I wrote implementing it.

@tjkuson
Copy link
Contributor

tjkuson commented Jul 11, 2023

I believe this was implemented last night! #5669

It should be in version 0.0.278.

@jakkdl
Copy link
Author

jakkdl commented Jul 11, 2023

Whoa, so fast! I didn't even consider checking whether it was already implemented, I'll make sure to do that next time. Thanks! 🚀 🚀

@jakkdl jakkdl closed this as completed Jul 11, 2023
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

No branches or pull requests

2 participants