Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new configuration setting lint.pydocstyle.allow-missing-docstring-nested-class-names #11211

Open
CarrotManMatt opened this issue Apr 30, 2024 · 2 comments
Labels
configuration Related to settings and configuration docstring Related to docstring linting or formatting

Comments

@CarrotManMatt
Copy link

This setting would be used by linting rule D106.
It would be of type list[str] representing the names of public nested classes that are allowed to not contain a docstring.
The format would be similar to lint.pylint.allow-dunder-method-names.

The major example for the usefulness of this rule would be for creating certain classes within the Django web framework, that require a nested Meta class. Models, ModelForms, some generic class-based-Views and ModelAdmin classes all require a Meta class to define certain functionality. It is superfluous to include a docstring for every definition of the Meta class as they all serve a similar purpose, and are used only by the Django runtime in the background. They should not be accessed by any project-code.

When a developer doesn't want to include docstrings purposefully for a specific nested-class name (see the example above) it is annoying to have to use the # noqa: D106 assertion on every line that the class name is used. This rule would prevent the repeated use of this ignore statement.

@MichaReiser
Copy link
Member

Thanks for opening this. I wonder if we could do better once we have a multifile analysis and maintain such a non-configurable allow list. But maybe that's too opinionated?

@MichaReiser MichaReiser added the configuration Related to settings and configuration label Apr 30, 2024
@AlexWaygood AlexWaygood added the docstring Related to docstring linting or formatting label Apr 30, 2024
@CarrotManMatt
Copy link
Author

maintain such a non-configurable allow list

As in a hard coded set of values that are ignored? What is the benefit of not allowing users to customise the list? At the minimum the hard coded ones could just be the defaults, like some of the other configuration lists that have defaults that can be extended by users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Related to settings and configuration docstring Related to docstring linting or formatting
Projects
None yet
Development

No branches or pull requests

3 participants