A lambda takes a different number of arguments than the builtin calls it with
What it finds
sorted(items, key=lambda: rank), map(lambda a, b: a + b, values): the builtins call their function with a fixed number of arguments, one for key= and for filter, and one per iterable for map. A lambda that takes another number raises TypeError on the first element.
Checked are lambdas given as key= to sorted, min, max and .sort(), and as the function of map and filter.
From the rule's source, callback_arity_mismatch.rs.
def order(items, pairs, values): a = sorted(items, key=lambda: 0)tx0 reports: sorted calls this lambda with 1 argument, which it does not take b = list(map(lambda x, y: x + y, values))tx0 reports: map calls this lambda with 1 argument c = list(filter(lambda a, b: a, values))tx0 reports: filter calls this lambda with 1 argument items.sort(key=lambda a, b: a)tx0 reports: sort calls this lambda with 1 argument d = sorted(items, key=lambda x: x.name) e = list(map(lambda x, y: x + y, values, pairs)) f = max(items, key=lambda x, default=0: x) return a, b, c, d, e, f 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:callback-arity-mismatch" = "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:callback-arity-mismatch] reason="..."tx0 explain tx0/python:callback-arity-mismatch shows the same in the terminal. Found a false positive? Report it.