str.join is given literals that are not strings
What it finds
", ".join([1, 2, 3]): str.join only joins strings, and raises TypeError for the first item that is not one. ", ".join(str(n) for n in numbers) converts them first.
Reported are number, True, False and None literals among the items of a list, tuple or set display passed to join on a string literal.
From the rule's source, join_non_strings.rs.
def render(names): a = ", ".join([1, 2, 3])tx0 reports: str.join raises TypeError for 1, which is not a string b = "-".join(("a", None))tx0 reports: str.join raises TypeError for None c = ", ".join(["a", "b"]) d = ", ".join(str(n) for n in names) return a, b, c, d Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/python:join-non-strings" = "off"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:join-non-strings] reason="..."tx0 explain tx0/python:join-non-strings shows the same in the terminal. Found a false positive? Report it.