Skip to content

Commit 19c0534

Browse files
clavedelunaPierre-Sassoulas
authored andcommitted
Fix missing-param-doc for escaped underscores (#7878)
Co-authored-by: Daniël van Noord <[email protected]> (cherry picked from commit 1913635)
1 parent e1856b2 commit 19c0534

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

Diff for: doc/whatsnew/fragments/7827.false_positive

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Fix ``missing-param-doc`` false positive when function parameter has an escaped underscore.
2+
3+
Closes #7827

Diff for: pylint/extensions/_check_docs_utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ class GoogleDocstring(Docstring):
471471

472472
re_param_line = re.compile(
473473
rf"""
474-
\s* ((?:\\?\*{{0,2}})?\w+) # identifier potentially with asterisks
474+
\s* ((?:\\?\*{{0,2}})?[\w\\]+) # identifier potentially with asterisks or escaped `\`
475475
\s* ( [(]
476476
{re_multiple_type}
477477
(?:,\s+optional)?

Diff for: tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.py

+12
Original file line numberDiff line numberDiff line change
@@ -433,3 +433,15 @@ def test_finds_multiple_complex_types_google(
433433
named_arg_nine,
434434
named_arg_ten,
435435
)
436+
437+
def test_escape_underscore(something: int, raise_: bool = False) -> bool:
438+
"""Tests param with escaped _ is handled correctly.
439+
440+
Args:
441+
something: the something
442+
raise\\_: the other
443+
444+
Returns:
445+
something
446+
"""
447+
return something and raise_

0 commit comments

Comments
 (0)