Python

Python

Made by DeepSource

Unused format string argument PYL-W1304

Anti-pattern
Major

The format string that uses named field(s), is used with an argument that is not required by the format string. It is recommended to remove unused keyword-arguments for a better readability.

Not preferred:

def greet_user(user):
    print(
        "Hi {name}!. Welcome to {location}.".format(
            name=user.first_name, location=user.updated_loc, age=user.age
        )
    )

Here, the argument age is nowhere used in the format string and should be removed.

Preferred:

def greet_user(user):
    print(
        "Hi {name}!. Welcome to {location}.".format(
            name=user.first_name, location=user.updated_loc
        )
    )