Last updated: Apr 5, 2024
Reading time·3 min

The "Missing module docstring pylint(missing-module-docstring)" warning is shown when a module has no docstring.

One way to get rid of the warning is to specify a documentation string on the first line of the module.
"""Module has a function that prints the name of my site""" def print_site_name(): site = 'bobbyhadz.com' print(site)
Note that empty modules don't require a docstring.
The module's docstring is specified on the first line using a triple-quoted string.
If you add the code above to a Python file, you will see that the "Missing module docstring" warning is no longer shown.
However, you might now be seeing the warning "Missing function or method docstring pylint(missing-function-docstring)".

You can add a documentation string below the function's definition line
def abc(): to describe what the function does.
"""Module has a function that prints the name of my site""" def print_site_name(): """Function printing the name of my site""" site = 'bobbyhadz.com' print(site)
Now the main.py module has a documentation string and a docstring for the
function, so the warnings are no longer shown.
If you work with classes, you might get the "Missing class docstring pylint(missing-class-docstring)" Pylint warning.

You have to add a documentation string to the class just like in the previous examples.
"""Module has a function that prints the name of my site""" class Employee(): """Used to create Employee instances""" def __init__(self, name): self.salary = 100 self.name = name
Make sure to also set a docstring in your methods.
"""Module has a function that prints the name of my site""" class Employee(): """Used to create Employee instances""" def __init__(self, name): self.salary = 100 self.name = name def print_name(self): """Prints the name of the employee instance""" print(self.name)
The print_name method of the Employee class also has a documentation string.
pylintrcYou can also disable the "Missing module docstring" warning in your pylintrc
file.
In your pylintrc file, find the disable key and add the following 3 values:
missing-module-docstringmissing-function-docstringmissing-class-docstringdisable=missing-module-docstring, missing-function-docstring, missing-class-docstring

The example disables the 3 warnings but you can adjust this depending on your needs.
After I've saved the pylintrc and
restarted Visual Studio Code, no warnings
are shown in the following file.
def print_site_name(): site = 'bobbyhadz.com' print(site) class Employee(): def __init__(self, name): self.salary = 100 self.name = name def print_name(self): print(self.name)

You can also disable the warning directly in Visual Studio Code.
Ctrl + Shift + P (or Command + Shift + P on macOS).F1 to open the Command Palette.Type user settings json.
Click on Preferences: Open User Settings (JSON)

python.linting.pylintArgs property to your settings.json file.{ "python.linting.pylintArgs": [ "--disable=missing-module-docstring", "--disable=missing-function-docstring", "--disable=missing-class-docstring" ], }

Note:
--disable= keys to your existing
python.linting.pylintArgs array if it already exists in settings.json.Save the settings.json file and the missing module docstring warning will be
disabled.
If you only want to disable the warning for your current project, use the local
.vscode/settings.json file instead.
In the root directory of your project, create a .vscode folder.
Create a settings.json file in the .vscode folder.
Add the following code to your settings.json file.
{ "python.linting.pylintArgs": [ "--disable=missing-module-docstring", "--disable=missing-function-docstring", "--disable=missing-class-docstring" ] }

The properties in your local .vscode/setting.json only apply to the current
project and override any global configuration.
If the issue persists, restart Visual Studio Code.
I've also written a detailed, step-by-step guide on how to disable specific Pylint warnings or all warnings in a file.
If you get the warning "String statement has no effect Pylint (pointless-string-statement)", check out the following article.