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

Fix missing-param-doc FP #7878

Merged
merged 4 commits into from Dec 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/7827.false_positive
@@ -0,0 +1,3 @@
Fix ``missing-param-doc`` false positive when function parameter has escaped underscore.
clavedeluna marked this conversation as resolved.
Show resolved Hide resolved

Closes #7827
2 changes: 1 addition & 1 deletion pylint/extensions/_check_docs_utils.py
Expand Up @@ -644,7 +644,7 @@ def match_param_docs(self) -> tuple[set[str], set[str]]:
entries = self._parse_section(self.re_param_section)
entries.extend(self._parse_section(self.re_keyword_param_section))
for entry in entries:
match = self.re_param_line.match(entry)
match = self.re_param_line.match(entry.replace("\\", ""))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we change self._re_param_line? We can include \\ there.

In any case, we are also replacing \\a bit further down here so that should be fixed as well then if we continue down the current road.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea how to change _re_param_line, it's really difficult to read. If you can, plz do paste your regex here!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I'd rather not touch it as well, but just replacing all \\ seems error prone as well.
I think it should be as easy as allowing both \w and \\ in _re_param_line. You can check this with regex101.com

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be as easy

Oh I tried, I really tried 🀣 , but nothing quite "works". As soon as you try to add some variation of (\)* or something (Tried lots of ways), it breaks other tests!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In any case, we are also replacing \a bit further down here so that should be fixed as well then if we continue down the current road.

reasonable and doesn't seem to break tests

if not match:
continue

Expand Down
Expand Up @@ -433,3 +433,15 @@ def test_finds_multiple_complex_types_google(
named_arg_nine,
named_arg_ten,
)

def test_escape_underscore(something: int, raise_: bool = False) -> bool:
"""Tests param with _ is handled correctly.
clavedeluna marked this conversation as resolved.
Show resolved Hide resolved

Args:
something: the something
raise\\_: the other

Returns:
something
"""
return something and raise_