A call does not fit the parameters of a function defined in the same file

tx0/python:call-arguments-mismatchdefaultwarningbug

What it finds

resize(image, 640, 480, True) where def resize(image, width, height): is defined in the same file: a call that passes more positional arguments than the function takes, leaves out a required one, names a parameter that does not exist, or gives one parameter twice raises TypeError when it runs.

Only calls by name of functions defined once in the file, without decorators and not as methods, are checked, so the signature is known. Calls that unpack *args or **kwargs are checked only for what does not depend on them.

From the rule's source, call_arguments_mismatch.rs.

Example from the rule's tests
def resize(image, width, height=0, *, keep=False):    return image, width, height, keep  def variadic(*args, **kwargs):    return args, kwargs  def use(img, options):    resize(img, 1, 2, 3)tx0 reports: calling resize: this call passes 4 positional arguments, but the function takes 3    resize(img)tx0 reports: calling resize: this call leaves out the required argument width    resize(img, 1, size=2)tx0 reports: calling resize: the function has no parameter size    resize(img, 1, width=2)tx0 reports: calling resize: width is given both by position and by keyword    resize(img, 1, keep=True)    resize(img, width=1, height=2)    resize(*options)    variadic(1, 2, x=3)
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 in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/python:call-arguments-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:call-arguments-mismatch] reason="..."

tx0 explain tx0/python:call-arguments-mismatch shows the same in the terminal. Found a false positive? Report it.