Skip to content

Files

Latest commit

 

History

History
31 lines (19 loc) · 756 Bytes

unexpected-keyword-arg.md

File metadata and controls

31 lines (19 loc) · 756 Bytes

Pattern: Unexpected keyword argument in function call

Issue: -

Description

Python will raise a TypeError at runtime if function definition does not expect keyword argument. Modify the function to support keyword arguments or pass the parameter as supported keyword or a positional parameter to resolve this issue.

Example of incorrect code:

def calc_area(width):
    return width * 2

calc_area(height = 12)

Example of correct code:

def calc_area(width):
    return width * 2

calc_area(width = 12) # passing expected keyword
calc_area(12) # passing positional parameter

Further Reading