From 9f803946c38f899c1129c5c66752dfda67881b39 Mon Sep 17 00:00:00 2001 From: Peter Prescott Date: Thu, 17 Mar 2022 13:26:03 +0000 Subject: [PATCH 1/3] Add function to check line_str is_end_of_signature --- numdoclint/helper.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/numdoclint/helper.py b/numdoclint/helper.py index 10f915e..962793c 100644 --- a/numdoclint/helper.py +++ b/numdoclint/helper.py @@ -404,7 +404,7 @@ def get_func_overall_docstring( is_docstring_last_line = True line_indent_num = get_line_indent_num(line_str=line_str) if (line_indent_num < indent_num and line_str != '' - and line_str.strip() != '):' + and not is_end_of_signature(line_str) and not is_docstring_line and not is_docstring_last_line): break @@ -445,6 +445,34 @@ def get_func_overall_docstring( return docstring +def is_end_of_signature(line_str: str) -> bool: + """ + Get a boolean value as to whether line_str represents the end of a + function signature or not. + + Parameters + ---------- + line_str : str + The target line string. + + Returns + ------- + bool + """ + + try: + line_str = line_str.strip() + assert line_str[0] == ')' + assert line_str[-1] == ':' + + if len(line_str)>2: + line_str = line_str.replace(' ','') + assert line_str[1:3] == '->' + return True + except Exception as e: + return False + + def _type_anotation_comment_exists(line_str: str) -> bool: """ Get a boolean value whether type annotation comment exists From 1f690f32395debfb13a215633938853aae2cd681 Mon Sep 17 00:00:00 2001 From: Peter Prescott Date: Thu, 17 Mar 2022 16:14:25 +0000 Subject: [PATCH 2/3] Use is_end_of_signature in get_func_str --- numdoclint/helper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numdoclint/helper.py b/numdoclint/helper.py index 962793c..e255260 100644 --- a/numdoclint/helper.py +++ b/numdoclint/helper.py @@ -1337,7 +1337,7 @@ def get_func_str(module_str: str, func_name: str) -> str: line_str = line_str.strip() if line_str == '': continue - if line_str.strip() == '):': + if is_end_of_signature(line_str): continue last_line_idx = i break From 6305f2af703ef1897dc031c4de11915e308a92ae Mon Sep 17 00:00:00 2001 From: Peter Prescott Date: Thu, 17 Mar 2022 16:15:13 +0000 Subject: [PATCH 3/3] Increment patch number of semantic version to reflect bugfix --- numdoclint/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numdoclint/__init__.py b/numdoclint/__init__.py index ca1d583..cfb9c81 100644 --- a/numdoclint/__init__.py +++ b/numdoclint/__init__.py @@ -17,4 +17,4 @@ check_python_module, check_python_module_recursively) -__version__: str = '0.1.8' +__version__: str = '0.1.9'