-
Notifications
You must be signed in to change notification settings - Fork 2k
Recognize charsets in different orders (FURB156) #21144
Copy link
Copy link
Closed
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Summary
Instead of:
if c in "abcdefghijklmnopqrstuvwxyz":
print(c)Use:
from string import ascii_lowercase
if c in ascii_lowercase:
print(c)And more generally:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ->string.ascii_lettersabcdefghijklmnopqrstuvwxyz->string.ascii_lowercaseABCDEFGHIJKLMNOPQRSTUVWXYZ->string.ascii_uppercase0123456789->string.digits0123456789abcdefABCDEF->string.hexdigits01234567->string.octdigits
The main reason is, when using a string literal like abcdefghijklmopqrstuvwxyz it's not abvious when a letter is missing (oops, just did it, did you see it?), so it's a potential source of errors.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
ruleImplementing or modifying a lint ruleImplementing or modifying a lint rule