startswith or endswith is called several times on one value, joined with or

tx0/python:repeated-prefix-teststrictnotestyle

What it finds

name.startswith("a") or name.startswith("b") calls the method twice; both methods take a tuple of prefixes or suffixes: name.startswith(("a", "b")). Reported are chains of or with at least two calls of the same method on the same expression, each with one argument.

From the rule's source, repeated_prefix_test.rs.

Example from the rule's tests
def kind(name, other):    if name.startswith("a") or name.startswith("b"):tx0 reports: startswith is called several times on one value        return 1    if name.endswith(".py") or other or name.endswith(".pyi"):tx0 reports: endswith is called several times        return 2    if name.startswith("a") or other.startswith("b"):        return 3    return name.startswith("a") and name.startswith("ab")
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:repeated-prefix-test" = "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:repeated-prefix-test] reason="..."

tx0 explain tx0/python:repeated-prefix-test shows the same in the terminal. Found a false positive? Report it.