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.

So in practice, do this


class SomeModel(models.Model):
    some_field = models.CharField()

Instead of this


class SomeModel(models.Model):
    some_field = models.CharField(blank=False)

Are you affected? Check with
pip install django-doctor
.

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.