22

I'm using the pygame module on VS Code and I ran into the issue where the pygame has not init member. I followed the solutions to this link. I edited the user settings and added

"python.linting.pylintArgs": [
    "--extension-pkg-whitelist=pygame",
    "--unsafe-load-any-extension=y"
]

to the end of the json file

The pygame problem was resolved. However, when I use import random. I get this warning:

Missing module docstringpylint(missing-module-docstring)

How do I make it go away? Also, is there a better way to resolve the init problem of pygame?

starball
  • 20,030
  • 7
  • 43
  • 238
  • 1
    I think the warning missing doc string is from your py file not from import random. Try adding some doc string at the top of your file describing what the .py file is for. – Mahesh Anakali Jan 29 '21 at 05:47

5 Answers5

35

A python module's docstring documents what the contents of that file are for.

You can solve this error by adding a docstring at the top of the module:

"""
Provides some arithmetic functions
"""

def add(a, b):
  """Add two numbers"""
  return a + b

def mult(a, b): 
  """Multiply two numbers"""
  return a * b

Read more at https://www.python.org/dev/peps/pep-0257/#multi-line-docstrings

Benny Powers
  • 5,398
  • 4
  • 32
  • 55
21

I just figured out what docstrings are. They just describe the function or class. It's enclosed in three double quotation marks or single quotation marks. This helped me.

To remove docstring warnings in VSCode, I just added "--disable=C0111" to "python.linting.pylintArgs": [], which was in the User's JSON settings.

  • 4
    For your reference: `C0114 (missing-module-docstring); C0115 (missing-class-docstring) C0116 (missing-function-docstring)`. Also you can mark your reply as an answer for more people who have the same question to reach this solution. – Molly Wang-MSFT Jan 29 '21 at 08:52
5

I added the settings below in VsCode to disable all the docstring warnings.

"python.linting.pylintArgs": [
  "--disable=missing-module-docstring",
  "--disable=missing-class-docstring",
  "--disable=missing-function-docstring"
]
sajeyks mwangi
  • 549
  • 8
  • 20
ikhvjs
  • 5,316
  • 2
  • 13
  • 36
0

This error is coming out when we are using pylint in the directory that doesn't have .pylintrc. Go to directory which has .pylintrc and run from there.

Example:

test/ test1.py test2/test2.py .pylintrc

If you want to run pylint for test2.py inside test/test2 then you will get that error.

test/test2$ pylint test2.py  is wrong.

test$ pylint test2.py is correct.
0

This Answer is updated with the docs of the extension add below code in vscode's settings.json

"pylint.args": [
    "--disable=missing-module-docstring",
    "--disable=missing-class-docstring",
    "--disable=missing-function-docstring"
],

this will disable the warnings for module, class and function docstring

ref: extension's docs