Skip to content

Add exclusions for D103 #10016

@clairem-sl

Description

@clairem-sl

With my current ruff (version 0.2.1), it keeps warning me that main() has no docstring (rule D103).

For me, I see no need for main() to ever have a docstring. After all, it's the main() function anyways, and I always use the if __name__ == "__main__" invocation to start it, and functionalities that may find use in other modules are already extracted to their own functions.

That results in me having to add # noqa: D103 every single time I create a new __main__.py, and it gets old quickly.

It would be nice if we have this configuration knob:

[tool.ruff.lint.pydocstyle]
allow-undocumented = ["main"]

This knob will control the behavior of rules D100 to D104.

A more granular approach can be implemented as well, for instance:

[tool.ruff.lint.pydocstyle]
allow-undocumented-public-function = ["main", "get_options"]
allow-undocumented-public-class = ["Options"]
allow-undocumented-public-method = ["SomeClass.public_method"]
# ... and so on, following pydocstyle rule names in https://docs.astral.sh/ruff/rules/#pydocstyle-d

(The allow-undocumented-public-(function|class) examples above are particularly useful for me because I define a Protocol named Options, and I cast() the result of get_options() [parses CLI for options using argparse] into Options for easy reference in main() and other functions that uses the options from CLI. For example, here, here, here, and here)

Metadata

Metadata

Assignees

No one assigned

    Labels

    configurationRelated to settings and configurationdocstringRelated to docstring linting or formatting

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions