How can I disable pylint's missing-module-docstring for unit tests?
Asked Answered
H

1

7

I'm a big fan of pylint's built-in docstring checker. I'm very happy to require docstrings on all my classes, all my functions, and all my modules.

What I don't like, however, is that pylint also wants docstrings on all my test modules and all my pytest test functions. This leads to low-value docstrings like the following:

"""Tests for foo.py"""

from foo import bar

def test_bar():
    """Tests for bar"""
    assert bar(1) == 2

I've been able to disable the function-level docstring requirement using no-docstring-rgx in my .pylintrc file:

[MASTER]
no-docstring-rgx=^(_|test_)

This takes care of the missing-function-docstring / C0116 error.

But I haven't been able to find a way to disable the missing-module-docstring / C0114 error just for files ending with _test.py. Is this possible with pylint?

Hennebery answered 19/1, 2023 at 22:38 Comment(1)
I would also like to know the answer, can someone help please?Chops
F
0

This sound like a new feature, I don't think an issue is opened for it. You can do so here

Faefaeces answered 23/1, 2023 at 10:58 Comment(1)
Filed github.com/PyCQA/pylint/issues/8106Hennebery

© 2022 - 2024 — McMap. All rights reserved.