Skip to content

Commit 6004ccf

Browse files
committed
fix: Increase maximum recursion limit in case of deeply nested ASTs (rare occurrence)
Issue-griffe-402: mkdocstrings/griffe#402
1 parent 3a0bb1e commit 6004ccf

File tree

1 file changed

+4
-0
lines changed
  • src/mkdocstrings_handlers/python/_internal

1 file changed

+4
-0
lines changed

src/mkdocstrings_handlers/python/_internal/handler.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,10 @@ def get_handler(
408408
Returns:
409409
An instance of `PythonHandler`.
410410
"""
411+
# In rare cases, Griffe hits the recursion limit because of deeply-nested ASTs.
412+
# We therefore increase the limit here, once, before Griffe is used to collect or render stuff.
413+
sys.setrecursionlimit(max(sys.getrecursionlimit(), 2000))
414+
411415
base_dir = Path(tool_config.config_file_path or "./mkdocs.yml").parent
412416
if "inventories" not in handler_config and "import" in handler_config:
413417
warn("The 'import' key is renamed 'inventories' for the Python handler", FutureWarning, stacklevel=1)

0 commit comments

Comments
 (0)