A non-capturing group of a pattern has no quantifier and no alternatives, so it groups nothing

tx0/python:regex-needless-groupallnotestyle/conventionsdepth faststyle

What it finds

(?:abc) without a following quantifier and without | inside matches exactly what abc does; the parentheses only add noise.

From the rule's source, regex_needless_group.rs.

Example from the rule's tests
import re a = re.compile(r"(?:abc)d")tx0 reports: a non-capturing group without quantifier or | changes nothingb = re.compile(r"(?:abc)+")c = re.compile(r"(?:a|b)c")
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 all tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/python:regex-needless-group" = "note"

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-needless-group] reason="..."

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