diff --git a/CHANGELOG.md b/CHANGELOG.md index fca3f4e..1b7b12f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ - Fixed - Fixed a bug where raise/return/yield statements in match-case blocks are incorrectly identified +- Improved + - Used a try/catch block to capture potential recursion error, potentially + due to too complex functions/classes + (https://github.com/jsh9/pydoclint/issues/65) - Full diff - https://github.com/jsh9/pydoclint/compare/0.1.9...0.2.0 diff --git a/pydoclint/utils/generic.py b/pydoclint/utils/generic.py index b37dc05..d4b748f 100644 --- a/pydoclint/utils/generic.py +++ b/pydoclint/utils/generic.py @@ -18,7 +18,13 @@ def collectFuncArgs(node: FuncOrAsyncFuncDef) -> List[ast.arg]: allArgs.extend(node.args.kwonlyargs) if node.args.vararg is not None: - vararg = copy.deepcopy(node.args.vararg) + try: + vararg = copy.deepcopy(node.args.vararg) + except RecursionError: + # In rare occasions, using deepcopy could trigger recursion errors + # if the underlying Python code is too complex. And example for + # it is https://github.com/jsh9/pydoclint/issues/65 + vararg = copy.copy(node.args.vararg) # This is a hacky way to ensure that users write '*args' instead # of 'args' in the docstring, as per the style guide of numpy: @@ -29,7 +35,13 @@ def collectFuncArgs(node: FuncOrAsyncFuncDef) -> List[ast.arg]: allArgs.append(vararg) if node.args.kwarg is not None: - kwarg = copy.deepcopy(node.args.kwarg) + try: + kwarg = copy.deepcopy(node.args.kwarg) + except RecursionError: + # In rare occasions, using deepcopy could trigger recursion errors + # if the underlying Python code is too complex. And example for + # it is https://github.com/jsh9/pydoclint/issues/65 + kwarg = copy.copy(node.args.kwarg) # This is a hacky way to ensure that users write '**kwargs' instead # of 'kwargs' in the docstring, as per the style guide of numpy: