diff --git a/tools/pylint-extensions/azure-pylint-guidelines-checker/pylint_guidelines_checker.py b/tools/pylint-extensions/azure-pylint-guidelines-checker/pylint_guidelines_checker.py index 124caeb3fdf..7fa8ce6a0bd 100644 --- a/tools/pylint-extensions/azure-pylint-guidelines-checker/pylint_guidelines_checker.py +++ b/tools/pylint-extensions/azure-pylint-guidelines-checker/pylint_guidelines_checker.py @@ -1328,6 +1328,11 @@ def check_parameters(self, node): if line.startswith("param") and line.count(" ") == 2: _, param_type, param = line.split(" ") docparams[param] = param_type + # if the param has its type on the same line with additional spaces + if line.startswith("param") and line.count(" ") > 2: + param = line.split(" ")[-1] + param_type = ("").join(line.split(" ")[1:-1]) + docparams[param] = param_type if line.startswith("type"): param = line.split("type ")[1] if param in docparams: diff --git a/tools/pylint-extensions/azure-pylint-guidelines-checker/tests/test_pylint_custom_plugins.py b/tools/pylint-extensions/azure-pylint-guidelines-checker/tests/test_pylint_custom_plugins.py index a2f9d2dc1b4..3dfa27cdc9a 100644 --- a/tools/pylint-extensions/azure-pylint-guidelines-checker/tests/test_pylint_custom_plugins.py +++ b/tools/pylint-extensions/azure-pylint-guidelines-checker/tests/test_pylint_custom_plugins.py @@ -3480,4 +3480,30 @@ def function_foo(self) -> Dict[str,str]: end_col_offset=16 ), ): + self.checker.visit_functiondef(node) + + def test_docstring_type_has_space(self): + # Don't error if there is extra spacing in the type + node = astroid.extract_node( + """ + def function_foo(x): + ''' + :param dict[str, int] x: x + ''' + """ + ) + with self.assertNoMessages(): + self.checker.visit_functiondef(node) + + def test_docstring_type_has_many_spaces(self): + # Don't error if there is extra spacing around the type + node = astroid.extract_node( + """ + def function_foo(x): + ''' + :param dict[str, int] x: x + ''' + """ + ) + with self.assertNoMessages(): self.checker.visit_functiondef(node) \ No newline at end of file