Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
redundant-u-string-prefix
checker (#4804)
* Add ``redundant-u-string-prefix`` checker This adds a checker for u-prefixes for strings, as used in Python 2. It only work in python 3.8 and above. Closes #4102
- Loading branch information
1 parent
7d84a32
commit 865765c
Showing
19 changed files
with
85 additions
and
28 deletions.
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
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
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
anomalous-backslash-in-string:7:5::"Anomalous backslash in string: '\['. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:7:7::"Anomalous backslash in string: '\]'. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:8:8::"Anomalous backslash in string: '\/'. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:9:20::"Anomalous backslash in string: '\`'. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:16:15::"Anomalous backslash in string: '\o'. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:16:20::"Anomalous backslash in string: '\o'. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:18:13::"Anomalous backslash in string: '\8'. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:18:17::"Anomalous backslash in string: '\9'. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:31:42::"Anomalous backslash in string: '\P'. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:8:5::"Anomalous backslash in string: '\['. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:8:7::"Anomalous backslash in string: '\]'. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:9:8::"Anomalous backslash in string: '\/'. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:10:20::"Anomalous backslash in string: '\`'. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:17:15::"Anomalous backslash in string: '\o'. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:17:20::"Anomalous backslash in string: '\o'. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:19:13::"Anomalous backslash in string: '\8'. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:19:17::"Anomalous backslash in string: '\9'. String constant might be missing an r prefix." | ||
anomalous-backslash-in-string:32:42::"Anomalous backslash in string: '\P'. String constant might be missing an r prefix." |
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
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
raising-format-tuple:10:4:bad_percent:Exception arguments suggest string formatting might be intended | ||
raising-format-tuple:18:4:bad_multiarg:Exception arguments suggest string formatting might be intended | ||
raising-format-tuple:26:4:bad_braces:Exception arguments suggest string formatting might be intended | ||
raising-format-tuple:34:4:bad_multistring:Exception arguments suggest string formatting might be intended | ||
raising-format-tuple:40:4:bad_triplequote:Exception arguments suggest string formatting might be intended | ||
raising-format-tuple:46:4:bad_unicode:Exception arguments suggest string formatting might be intended | ||
raising-format-tuple:51:4:raise_something_without_name:Exception arguments suggest string formatting might be intended | ||
raising-format-tuple:11:4:bad_percent:Exception arguments suggest string formatting might be intended | ||
raising-format-tuple:19:4:bad_multiarg:Exception arguments suggest string formatting might be intended | ||
raising-format-tuple:27:4:bad_braces:Exception arguments suggest string formatting might be intended | ||
raising-format-tuple:35:4:bad_multistring:Exception arguments suggest string formatting might be intended | ||
raising-format-tuple:41:4:bad_triplequote:Exception arguments suggest string formatting might be intended | ||
raising-format-tuple:47:4:bad_unicode:Exception arguments suggest string formatting might be intended | ||
raising-format-tuple:52:4:raise_something_without_name:Exception arguments suggest string formatting might be intended |
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,14 @@ | ||
""""Checks for redundant u-prefixes for strings""" | ||
# pylint: disable=missing-function-docstring | ||
|
||
def print_good(): | ||
print("String") | ||
print(f"String{1 + 1}") | ||
|
||
|
||
def print_bad(): | ||
print(u"String") # [redundant-u-string-prefix] | ||
print(u'String') # [redundant-u-string-prefix] | ||
print([u"String", u"String2"]) # [redundant-u-string-prefix, redundant-u-string-prefix] | ||
print((u"String", u"String2")) # [redundant-u-string-prefix, redundant-u-string-prefix] | ||
print({1: u"String"}) # [redundant-u-string-prefix] |
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,2 @@ | ||
[testoptions] | ||
min_pyver=3.8 |
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,7 @@ | ||
redundant-u-string-prefix:10:10::The u prefix for strings is no longer necessary in Python >=3.0:HIGH | ||
redundant-u-string-prefix:11:10::The u prefix for strings is no longer necessary in Python >=3.0:HIGH | ||
redundant-u-string-prefix:12:11::The u prefix for strings is no longer necessary in Python >=3.0:HIGH | ||
redundant-u-string-prefix:12:22::The u prefix for strings is no longer necessary in Python >=3.0:HIGH | ||
redundant-u-string-prefix:13:11::The u prefix for strings is no longer necessary in Python >=3.0:HIGH | ||
redundant-u-string-prefix:13:22::The u prefix for strings is no longer necessary in Python >=3.0:HIGH | ||
redundant-u-string-prefix:14:14::The u prefix for strings is no longer necessary in Python >=3.0:HIGH |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""Suspicious str.strip calls.""" | ||
# pylint: disable=redundant-u-string-prefix | ||
__revision__ = 1 | ||
|
||
''.strip('yo') | ||
|
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
bad-str-strip-call:7:0::Suspicious argument in str.strip call | ||
bad-str-strip-call:8:0::Suspicious argument in str.lstrip call | ||
bad-str-strip-call:9:0::Suspicious argument in bytes.rstrip call | ||
bad-str-strip-call:8:0::Suspicious argument in str.strip call | ||
bad-str-strip-call:9:0::Suspicious argument in str.lstrip call | ||
bad-str-strip-call:10:0::Suspicious argument in bytes.rstrip call |
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