-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add B034: re.sub/subn/split must pass flags/count/maxsplit as keyword…
… arguments (#398) * Add B034: re.sub/subn/split must pass flags/count/maxsplit as keyword arguments. * remove <3.8 check accidentally added back * Apply suggestions from code review Co-authored-by: Jelle Zijlstra <[email protected]> * update column in testcase * improved wording --------- Co-authored-by: Jelle Zijlstra <[email protected]>
- Loading branch information
1 parent
f1c391a
commit dea2e00
Showing
4 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import re | ||
from re import sub | ||
|
||
# error | ||
re.sub("a", "b", "aaa", re.IGNORECASE) | ||
re.sub("a", "b", "aaa", 5) | ||
re.sub("a", "b", "aaa", 5, re.IGNORECASE) | ||
re.subn("a", "b", "aaa", re.IGNORECASE) | ||
re.subn("a", "b", "aaa", 5) | ||
re.subn("a", "b", "aaa", 5, re.IGNORECASE) | ||
re.split(" ", "a a a a", re.I) | ||
re.split(" ", "a a a a", 2) | ||
re.split(" ", "a a a a", 2, re.I) | ||
|
||
# okay | ||
re.sub("a", "b", "aaa") | ||
re.sub("a", "b", "aaa", flags=re.IGNORECASE) | ||
re.sub("a", "b", "aaa", count=5) | ||
re.sub("a", "b", "aaa", count=5, flags=re.IGNORECASE) | ||
re.subn("a", "b", "aaa") | ||
re.subn("a", "b", "aaa", flags=re.IGNORECASE) | ||
re.subn("a", "b", "aaa", count=5) | ||
re.subn("a", "b", "aaa", count=5, flags=re.IGNORECASE) | ||
re.split(" ", "a a a a", flags=re.I) | ||
re.split(" ", "a a a a", maxsplit=2) | ||
re.split(" ", "a a a a", maxsplit=2, flags=re.I) | ||
|
||
|
||
# not covered | ||
sub("a", "b", "aaa", re.IGNORECASE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters