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

Enforce docparams consistently when docstring is not present #2738

Closed
kevinoid opened this issue Feb 11, 2019 · 3 comments · Fixed by #3916
Closed

Enforce docparams consistently when docstring is not present #2738

kevinoid opened this issue Feb 11, 2019 · 3 comments · Fixed by #3916
Labels
Enhancement ✨ Improvement to a component

Comments

@kevinoid
Copy link

Currently pylint.extensions.docparams produces missing-return-doc, missing-return-type-doc, and missing-yield-doc, missing-yield-type-doc errors for functions without a docstring. This differs from missing-param-doc, missing-raises-doc, and missing-type-doc which are not produced for functions without a docstring.

Since pylint.extensions.docparams does not use the no-docstring-rgx or docstring-min-length options, producing these errors for missing docstrings is problematic. It provides no way to configure pylint to warn about missing return/yield documentation only when documentation is required (e.g. ignoring undocumented private methods) which seems like a valuable use case.

Steps to reproduce

  1. Create .pylintrc with the following content:
[MASTER]
load-plugins = pylint.extensions.docparams

[BASIC]
accept-no-param-doc = no
accept-no-raise-doc = no
accept-no-return-doc = no
accept-no-yields-doc = no
  1. Create fixture_docparams_missing.py with the following content:
"""Fixture for testing missing documentation in docparams."""

def _private_func(param1):
    if param1:
        raise Exception('Example')
    return param1

def _private_func2(param1):
    yield param1
  1. Run pylint fixture_docparams_missing.py

Current behavior

************* Module fixture_docparams_missing
fixture_docparams_missing.py:3:0: W9011: Missing return documentation (missing-return-doc)
fixture_docparams_missing.py:3:0: W9012: Missing return type documentation (missing-return-type-doc)
fixture_docparams_missing.py:8:0: W9013: Missing yield documentation (missing-yield-doc)
fixture_docparams_missing.py:8:0: W9014: Missing yield type documentation (missing-yield-type-doc)

------------------------------------------------------------------
Your code has been rated at 3.33/10 (previous run: 3.33/10, +0.00)

Expected behavior

No errors (due to missing-docstring suppressed by default no-docstring-rgx).

Alternatively, all missing-* error types produced by pylint.extensions.docparams and a configuration option to suppress the errors in a similar way to no-docstring-rgx.

pylint --version output

From a local clone of 51e12f8:

__main__.py 2.3.0-dev1
astroid 2.1.0
Python 3.7.2+ (default, Feb  2 2019, 14:31:48) 
[GCC 8.2.0]

Thanks for considering,
Kevin

@PCManticore
Copy link
Contributor

Hey @kevinoid I think this makes sense, thanks for raising the issue. @AWhetter let me know if you have a different opinion.

@PCManticore PCManticore added the Enhancement ✨ Improvement to a component label Feb 18, 2019
@AWhetter
Copy link
Contributor

Makes sense to me too.
@PCManticore Is it possible to use the value of an option defined by another checker?

@PCManticore
Copy link
Contributor

@AWhetter Yep, you can use pylint.utils.get_global_option for that, e.g. get_global_option(self, "option-name", default=default_value)

hippo91 pushed a commit that referenced this issue Jan 9, 2021
* fix #2738

* doc updates

* add functional tests

* fix formattting

* fix formatting
orSolocate pushed a commit to orSolocate/pylint that referenced this issue Feb 1, 2021
…dev#3916)

* fix pylint-dev#2738

* doc updates

* add functional tests

* fix formattting

* fix formatting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement ✨ Improvement to a component
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants