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

False negative: missing numpy param doc when "default ..." in same line of "param : type" #6211

Open
vepain opened this issue Apr 6, 2022 · 8 comments
Labels
False Negative 🦋 No message is emitted but something is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation

Comments

@vepain
Copy link

vepain commented Apr 6, 2022

Bug description

False negative :
Warning "missing param doc" should'nt be raised when these type of docstring format:

def func(x: int = 0):
  """This is func.

  Parameter
  ---------
  x : int, default 0  # this raises the warning
    The x parameter
  """
  # ...

Configuration

[MASTER]
load-plugins =
    pylint.extensions.docstyle,
    pylint.extensions.docparams

[MESSAGES CONTROL]
enable = W

[BASIC]
accept-no-param-doc = no

Command used

pylint --rcfile=tox.ini a.py

Pylint output

"orientation" missing in parameter documentation

Expected behavior

No warning

In fact, numpy style doc says:

These are all equivalent:

copy : bool, default True
copy : bool, default=True
copy : bool, default: True

Pylint version

pylint 2.13.5
astroid 2.11.2
Python 3.9.12 (main, Mar 24 2022, 16:20:11) 
[GCC 9.4.0]

OS / Environment

Ubuntu 20.04

Additional dependencies

No response

@vepain vepain added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Apr 6, 2022
@Pierre-Sassoulas Pierre-Sassoulas added the Lib specific 💅 This affect the code from a particular library label May 13, 2022
@lkev
Copy link

lkev commented Jun 1, 2022

+1 having the same issue.

Just to add - the following does not raise any error, so maybe just allow items in parenthesis and/or the "default" word after the comma?

def func(x: int = 0):
  """This is func.

  Parameter
  ---------
  x : int, optional
    The x parameter, by default 0
  """
  # ...

@Pierre-Sassoulas Pierre-Sassoulas added Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Jun 23, 2022
@DanielNoord
Copy link
Collaborator

See https://numpydoc.readthedocs.io/en/latest/format.html#parameters and the failures in #7149.

@adam-grant-hendry
Copy link
Contributor

I am seeing this as well with

python 3.8.10
pylint 2.14.5

using

pylint.extensions.docparams

@DanielNoord Has this not been fixed yet?

@Pierre-Sassoulas Pierre-Sassoulas added False Negative 🦋 No message is emitted but something is wrong with the code and removed Lib specific 💅 This affect the code from a particular library labels Aug 24, 2022
@DanielNoord
Copy link
Collaborator

No, I don't think so. The linked PR fixed something different.

@adam-grant-hendry
Copy link
Contributor

@DanielNoord Can you point me to the section of code to review? I can submit a PR if you like.

@adam-grant-hendry
Copy link
Contributor

@DanielNoord Can you point me to the section of code to review? I can submit a PR if you like.

Actually, I'm assuming this is pylint/extensions/docparams.py. I'll submit a PR.

@Pierre-Sassoulas
Copy link
Member

That's right @adam-grant-hendry, most tests for this checker are in https://github.com/PyCQA/pylint/tree/main/tests/functional/ext/docparams

adam-grant-hendry added a commit to adam-grant-hendry/pylint that referenced this issue Aug 26, 2022
NumPy doc style guide permits using `default` in parameter
signatures.

Fixes: pylint-dev#6211
adam-grant-hendry added a commit to adam-grant-hendry/pylint that referenced this issue Aug 26, 2022
NumPy doc style guide permits using `default` in parameter
signatures.

Fixes: pylint-dev#6211
adam-grant-hendry added a commit to adam-grant-hendry/pylint that referenced this issue Aug 26, 2022
adam-grant-hendry added a commit to adam-grant-hendry/pylint that referenced this issue Aug 26, 2022
NumPy doc style guide permits using `default` in parameter
signatures.

Fixes: pylint-dev#6211
adam-grant-hendry added a commit to adam-grant-hendry/pylint that referenced this issue Aug 26, 2022
@adam-grant-hendry
Copy link
Contributor

adam-grant-hendry commented Aug 28, 2022

@lkev @vepain One note: you are using Parameter instead of Parameters (plural). Change this to Parameters. pylint checks for this docstring section using the plural form of the word, so if you don't write it like that, the docparams extension won't see any of your parameters:

re_param_section = re.compile(
        _re_section_template.format(r"(?:Args|Arguments|Parameters)"),
        re.X | re.S | re.M,
    )

and this is how it is written in the numpydoc Style Guide.

Note, this doesn't fix the bug, but wanted to point it out because you will silently think everything is fine when it is not.

DanielNoord pushed a commit to adam-grant-hendry/pylint that referenced this issue Sep 4, 2022
NumPy doc style guide permits using `default` in parameter
signatures.

Fixes: pylint-dev#6211
DanielNoord pushed a commit to adam-grant-hendry/pylint that referenced this issue Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
False Negative 🦋 No message is emitted but something is wrong with the code Needs PR This issue is accepted, sufficiently specified and now needs an implementation
Projects
None yet
Development

No branches or pull requests

5 participants