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
missing-param-doc differences between 2.11.1 and 2.12.1 #5452
Comments
Daniel's probably already all over this issue but I'll attach some artefacts just in case it makes life easier. This file includes the pylintrc we use (a slightly modified Google-external one), the test program test5452.py with four functions (the two with the multi-line param specifications, one with and one without colon, are the ones that raise an issue), and the output we get from pylint. |
I have not looked at this particular issue yet, just assigned myself to show that this in on my radar and on my todo list for soon™. (Also because I was likely the one we caused this with changes for Thanks for the examples, that will help fix this more easily 😄 |
Daniel et al, I think you need to look at this bit of code in
I'm not entirely certain what was going through the mind of the developer there, it appears that the In any case, the regex used for this captures all three groups whether the type is there or not. If it's not there, the second group (the parameter type) is set to None and the third group is still the description (it doesn't move to group 2), as per my debug code below (important lines begin with
If the code is instead changed into (no
then the first case in my test code still works, and the second one starts working, the two styles shown below:
The other two test cases don't work (the ones where the parameter name aren't followed by a colon) but I think you can make an argument that they ARE actually invalid, the colon being necessary to separate parameter from description. If you want those to work, you'll need to do some more work. I'd be happy with just what I've done so far but others may want more. For now, we've version locked our build system to 2.11.1 so we don't get affected by it. Hope that analysis has helped you bods out. AllanC. |
Thanks for the thorough analysis @allanc65. If you want you can make the PR yourself and become a contributor to diff --git a/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.py b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.py
new file mode 100644
index 00000000..920366cc
--- /dev/null
+++ b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.py
@@ -0,0 +1,18 @@
+"""Tests for missing-param-doc and missing-type-doc for Google style docstrings
+with accept-no-param-doc = no
+
+Styleguide:
+https://google.github.io/styleguide/pyguide.html#doc-function-args
+"""
+# pylint: disable=invalid-name
+
+
+def test_multi_line_parameters(param: int) -> None:
+ """Checks that multi line parameters lists are checkec correctly
+ See https://github.com/PyCQA/pylint/issues/5452
+
+ Args:
+ param:
+ a description
+ """
+ print(param)
diff --git a/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.rc b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.rc
new file mode 100644
index 00000000..dd77ffed
--- /dev/null
+++ b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.rc
@@ -0,0 +1,6 @@
+[MASTER]
+load-plugins = pylint.extensions.docparams
+
+[BASIC]
+accept-no-param-doc=no
+docstring-min-length: -1
diff --git a/pylint/extensions/_check_docs_utils.py b/pylint/extensions/_check_docs_utils.py
index 18c2ec0b..5227e74a 100644
--- a/pylint/extensions/_check_docs_utils.py
+++ b/pylint/extensions/_check_docs_utils.py
@@ -646,16 +646,9 @@ class GoogleDocstring(Docstring):
if not match:
continue
- # check if parameter has description only
- re_only_desc = re.search(":\n", entry)
- if re_only_desc:
- param_name = match.group(1)
- param_desc = match.group(2)
- param_type = None
- else:
- param_name = match.group(1)
- param_type = match.group(2)
- param_desc = match.group(3)
+ param_name = match.group(1)
+ param_type = match.group(2)
+ param_desc = match.group(3)
if param_type:
params_with_type.add(param_name) You'll only need to add a changelog entry in |
Daniel, I've made all those changes to a branch taken off the main branch but I'm not able to push to the repo using either my password or the token I got from Github as part of the attempted push. Not sure what the process is here but, if it's too much of a hassle, I'm happy to let you do it. If it's actually done via diff patching, that's way too primitive for my normal workflow. I'm more used to push, PR, approve and merge. If you do decide to do it yourself, the changes I made are exactly as you suggested but I spelt "checked" correctly :-) |
Are you trying to push to the As I said, if you already know this and are experiencing trouble with passwords and tokens locally disregard anything I said 😄
😄 |
No, I didn't know any of that. VsCode did give me the option of creating a fork but I thought that was heavy-handed, a totally separate repo. But, if you guys can bring stuff from a fork back into the main repo, that seems doable. Let me see if I can convince VsCode to give me that option again ... |
… Google-style docstrings.
Okay, done, that was less painful than I expected. The PR is from allanc65:issue-5452 to PyCQA:main, I hope that the right flow. |
Let me know if there's any deficiencies, I'm happy to fix. |
@allanc65 Please don't close issues if they haven't been resolved yet. If for whatever reason we end up not merging your PR then we would lose track of this issue 😉 |
Apologies, Daniel, I (wrongly) assumed you assigned this issue back to me for the purposes of closure. I'll know better next time. |
No worries! Everybody needs to learn stuff like this one time :) |
@DanielNoord : quick question (hopefully). I've improved the |
@allanc65 Hi, we're actually in the process of moving some of our current tests to that file as well. We're using unit tests to test these right now and want to start using the functional test. Sorry, I should have told you about this before! You can look at the Sphinx file to see what it will look like. |
That's fine, @DanielNoord - I attach the modified file here in case I get hit by a bus in the next few days but will otherwise wait for notification before doing anything further. |
Bug description
False positive on missing-param-doc when transitioning from Pylint 2.11.1 to 2.12.1, with code:
Code is:
Interestingly, if name and description on same line, it doesn't complain. The
re_param_line
regex forGoogleDocstring
inextensions/_check_docs_utils.py
seems to allow for a single line with colon, or multi-line with no colon\s* (\*{{0,2}}\w+)(\s?(:|\n))
but I couldn't get any multi-line working.See https://stackoverflow.com/questions/70196858/pylint-2-12-1-different-behaviour-from-2-11-1 for original question on SO.
Configuration
No response
Command used
Pylint output
Expected behavior
Expected no errors.
Pylint version
OS / Environment
Ubuntu and WSL2.
Additional dependencies
No response
The text was updated successfully, but these errors were encountered: