0

How can I avoid pylint to mark missing docstring in the main function, without removing any others from the default, like the __init__ method?

enter image description here

When I run

poetry run pylint src/* --no-docstring-rgx "main"

it overwrites the default value to avoid private methods that start with _. See the docs here

I don't want to override the default configuration, but add more rules to it. Can't figure out a way to achieve that.

Henrique Branco
  • 1,778
  • 1
  • 13
  • 40
  • No screenshots of text or code! Copy-paste the text into the question instead. https://idownvotedbecau.se/imageofcode and https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors/285557#285557 – sinoroc Mar 21 '23 at 09:50
  • 1
    What about adding an ignore comment for this line only? – sinoroc Mar 21 '23 at 09:52

1 Answers1

2

This can be achieved with:

pylint <module or directory> --no-docstring-rgx "^_|^main$"

where,

  • ^_ is the default value which matches function and class names beginning with _.

  • ^main$ matches function and class names with a value of main.

  • | matches either of the previous two regular expressions.

Alternatively, no-docstring-rgx can be defined in one of the configuration files which Pylint supports. For example a pyproject.toml file in the project root directory can have the following content:

[tool.pylint]
no-docstring-rgx="^_|^main$"
Mark Byrne
  • 85
  • 1
  • 5