diff --git a/doc/whatsnew/fragments/7827.false_positive b/doc/whatsnew/fragments/7827.false_positive new file mode 100644 index 0000000000..e981fa45f1 --- /dev/null +++ b/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 diff --git a/pylint/extensions/_check_docs_utils.py b/pylint/extensions/_check_docs_utils.py index 46f0a2ac6b..811bd67b57 100644 --- a/pylint/extensions/_check_docs_utils.py +++ b/pylint/extensions/_check_docs_utils.py @@ -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)? 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 index 18fbaf0490..92646a87f4 100644 --- a/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.py +++ b/tests/functional/ext/docparams/parameter/missing_param_doc_required_Google.py @@ -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_