How do I disable “missing docstring” warnings at a file-level in Pylint?

前端 未结 11 641
情书的邮戳
情书的邮戳 2020-12-12 14:18

Pylint throws errors that some of files are missing docstrings. I try and add docstrings to each class, method and function but it seems that Pylint also checks that files s

相关标签:
11条回答
  • 2020-12-12 14:50

    Edit "C:\Users\Your User\AppData\Roaming\Code\User\settings.json" and add these python.linting.pylintArgs lines at the end as shown below:

    {
        "team.showWelcomeMessage": false,
        "python.dataScience.sendSelectionToInteractiveWindow": true,
        "git.enableSmartCommit": true,
        "powershell.codeFormatting.useCorrectCasing": true,
        "files.autoSave": "onWindowChange",
        "python.linting.pylintArgs": [
            "--load-plugins=pylint_django",
            "--errors-only"
        ],
    }
    
    0 讨论(0)
  • 2020-12-12 14:52

    It's late, but still I found it useful. So sharing. Found this here.

    You can add "--errors-only" flag for pylint to disable warnings.

    To do this, go to settings. Edit the following line:

    "python.linting.pylintArgs": []

    As

    "python.linting.pylintArgs": ["--errors-only"]

    And you are good to go!

    0 讨论(0)
  • 2020-12-12 14:55

    In my case, with pylint 2.6.0, the missing docstring messages wouldn't disappear, even after explicitly disabling missing-module-docstring, missing-class-docstring and missing-function-docstring in my .pylintrc file. Finally, the following configuration worked for me:

    [MESSAGES CONTROL]
    
    disable=missing-docstring,empty-docstring
    

    Apparently, pylint 2.6.0 still validates docstrings unless both checks are disabled.

    0 讨论(0)
  • 2020-12-12 14:58

    With pylint 2.4 and above you can differentiate between the various missing-docstring by using the three following sub-messages:

    • C0114 (missing-module-docstring)
    • C0115 (missing-class-docstring)
    • C0116 (missing-function-docstring)

    So the following .pylintrc file should work:

    [MASTER]
    disable=
        C0114, # missing-module-docstring
    
    0 讨论(0)
  • 2020-12-12 14:59

    I think the fix is relative easy without disabling this feature.

    def kos_root():
        """Return the pathname of the KOS root directory."""
        global _kos_root
        if _kos_root: return _kos_root
    

    All you need to do is add the triple double quotes string in every function.

    0 讨论(0)
提交回复
热议问题