Skip to content

Commit

Permalink
Fix missing-param-doc for escaped underscores (#7878)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com>
(cherry picked from commit 1913635)
  • Loading branch information
clavedeluna authored and Pierre-Sassoulas committed Dec 4, 2022
1 parent e1856b2 commit 19c0534
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
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 an escaped underscore.

Closes #7827
2 changes: 1 addition & 1 deletion pylint/extensions/_check_docs_utils.py
Expand Up @@ -471,7 +471,7 @@ class GoogleDocstring(Docstring):

re_param_line = re.compile(
rf"""
\s* ((?:\\?\*{{0,2}})?\w+) # identifier potentially with asterisks
\s* ((?:\\?\*{{0,2}})?[\w\\]+) # identifier potentially with asterisks or escaped `\`
\s* ( [(]
{re_multiple_type}
(?:,\s+optional)?
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 escaped _ is handled correctly.
Args:
something: the something
raise\\_: the other
Returns:
something
"""
return something and raise_

0 comments on commit 19c0534

Please sign in to comment.