A quantifier of a regular expression is written in a longer form than needed, or does nothing

tx0/python:regex-verbose-quantifierstrictwarningstyle

What it finds

{1} repeats once, which is what an item does on its own; {0,}, {1,} and {0,1} are *, + and ? written out.

From the rule's source, regex_verbose_quantifier.rs.

Example from the rule's tests
import re a = re.compile(r"ab{1}c")tx0 reports: the quantifier {1} does nothingb = re.compile(r"ab{0,}c")tx0 reports: the quantifier {0,} is * written outc = re.compile(r"ab{2,3}c{2}")
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/python:regex-verbose-quantifier" = "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-verbose-quantifier] reason="..."

tx0 explain tx0/python:regex-verbose-quantifier shows the same in the terminal. Found a false positive? Report it.