The CPython interpreter does not check arguments type when functions are called. However a function can express the type it expects for each
argument in its documentation or by using Type Hints. Calling such a function with an argument
of a different type can easily create a bug. Even if it works right now it can fail later when APIs evolve or when type checks are added (ex: with
isinstance
).
This rule raises an issue when a function or method is called with an argument of a different type than the one described in its type annotations.
It also checks argument types for builtin functions.
Noncompliant Code Example
def func(var: str):
pass
func(42) # Noncompliant
len(1) # Noncompliant
Compliant Solution
def func(var: str):
pass
func("42")
len("1")
See