A bracket set in a pattern names the same character twice
What it finds
[a-z_a] lists a twice, once in the range and once on its own. The class matches the same either way, so the repetition is harmless in itself, but it often shows that a different character was meant, or that an unescaped - made a range where none was intended.
From the rule's source, regex_duplicate_class_member.rs.
import re a = re.compile(r"[a-z_a]+")tx0 reports: the character a appears twice in a character classb = re.compile(r"[0-9.,.]")tx0 reports: the character . appears twicec = re.compile(r"[a-zA-Z0-9_\-]")d = re.compile(r"[\d\s]") Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/python:regex-duplicate-class-member" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
# tx0: ignore[tx0/python:regex-duplicate-class-member] reason="..."tx0 explain tx0/python:regex-duplicate-class-member shows the same in the terminal. Found a false positive? Report it.