Skip to content
This repository was archived by the owner on Nov 3, 2023. It is now read-only.

Ignore missing docstring in main function of script #532

Closed
ajhynes7 opened this issue Apr 18, 2021 · 5 comments
Closed

Ignore missing docstring in main function of script #532

ajhynes7 opened this issue Apr 18, 2021 · 5 comments

Comments

@ajhynes7
Copy link

Hello,

I have several Python scripts with this format:

"""Description of the script."""


def main():
    # All of the script code.


if __name__ == "__main__":
    main()
    

It seems redundant to explain the script again inside the main function.

pydocstyle raises this error:

path/to/script.py:4 in public function `main`:
        D103: Missing docstring in public function

I don't want to ignore D103 because it's useful for functions in other modules.

I see that you have a --match option for selecting files that match a regular expression. Perhaps a feature could be added to ignore function names that match a regular expression?

Thanks.

@sigmavirus24
Copy link
Member

You can also use # noqa on the def main(): line iirc to disable this

@ajhynes7
Copy link
Author

Ok thanks, that works as well. Do you think it would be useful though to add a command line option for excluding a function based on a regular expression? Something like --match-function.

If so, I can try contributing the feature.

@sigmavirus24
Copy link
Member

I don't but I'm not a maintainer

@sambhav
Copy link
Member

sambhav commented May 17, 2021

Related to/Duplicate of #537

@sambhav sambhav closed this as completed May 17, 2021
@KaleabTessera
Copy link

This feature would be appreciated! Adding # noqa to many files is not ideal.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants