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 2 commits
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
9 changes: 3 additions & 6 deletions pylint/extensions/_check_docs_utils.py
Expand Up @@ -644,16 +644,13 @@ 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:
# Remove escape characters necessary for asterisks and trailing underscores
clavedeluna marked this conversation as resolved.
Show resolved Hide resolved
entry = entry.replace("\\", "")
match = self.re_param_line.match(entry)
if not match:
continue

param_name = match.group(1)
# Remove escape characters necessary for asterisks
param_name = param_name.replace("\\", "")

param_type = match.group(2)
param_desc = match.group(3)
param_name, param_type, param_desc = match.groups()

if param_type:
params_with_type.add(param_name)
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_