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.
The CPython interpreter does not check types of arguments when functions are called. However, a function can express the type it expects for each
argument in its documentation or by using Type Hints. While the code may initially work as
intended, not respecting the contract of an API may lead to bugs later when its implementation evolves or when type checks are added (i.e. with
isinstance).
This rule also checks argument types for built-in functions.
def func(var: str):
pass
func(42) # Noncompliant: 42 is not of type str.
round("not a number") # Noncompliant: the builtin function round requires a number as first parameter.
def func(var: str):
pass
func("42")
round(1.2)