Skip to content

REF003: library-function-arity

Call to a library function with arguments it cannot accept

Code REF003
Name library-function-arity
Category References (REF)
Default severity error
Enabled by default yes
Fix available no
ign-lint equivalent none

Checks calls of project library functions (core.util.fmt(...), through aliases and from core.util import fmt, and a module's calls of its own top-level functions) against the function's signature: too few or too many positional arguments, unknown keyword arguments and arguments passed twice. A call through another library module's import (m0.util.fmt() when m0 does from core import util, at any depth) is checked against the function the import leads to.

Only plain functions are checked: a name defined more than once in its module (conditional definitions, redefinitions, global assignments), a decorated function, a class or any other value is not. Neither is a function its module may replace at run time (the module runs exec, eval or execfile, writes globals() or sys.modules[__name__], sets the function's func_code or func_defaults, or a later from x import * may overwrite it), nor one that a script of the project assigns, deletes or replaces (core.util.fmt = f, setattr(core.util, 'fmt', f), core.util.__dict__[k] = v). Calls that unpack *args or **kwargs are only checked for errors the unpacking cannot hide. Calls inside a try that catches TypeError or Exception are checked too: a wrong call is a bug, not a handled condition.

The call raises TypeError at run time. A wrong argument count usually means the function's signature changed and this caller was not updated.

# core/util: def fmt(value, digits=2)
core.util.fmt(value, 2, 'kW')

Use instead:

core.util.fmt(value, 2)

Generated from the rule metadata by iglint generate-docs; iglint rule REF003 prints the same page in the terminal. Source: docs/rules/REF003.md.