Redundant default arguments

Stating defaults add complexity when reading the code but does not change Django's behaviour.

Python allows function arguments to have default values. The default value is used when the function is called without the argument.

Redundant default arguments are explicitly passing in default values when calling a function.

Redundant default arguments are noise. They don't add value but do add maintenance overhead. The code will execute the same without specifying them. Reduce the amount of code that needs to be read and maintained by deleting redundant default arguments.

If we spot this issue in your GitHub pull request we give this advice:

models.pymaintainabilitylow
class CommentModel(models.Model):
-
    body = models.TextField(null=False,editable=True)
+
    body = models.TextField()
    date = models.DateField()

Stating defaults add complexity when reading the code but does not change Django's behaviour.

Read more
Protect your pull requests from over 40 types of common Django technical debts with our GitHub code review bot.

Configuring this check

Django Doctor will run this check by default. No configuration is needed but the check can be turned on/off using check code redundant-default-args in your pyproject.toml file.

Read more about configuring Django Doctor.