From 37021599065319d53f01c0ddbf3c644f7a16d5d5 Mon Sep 17 00:00:00 2001 From: Anton Larionov Date: Sun, 1 Feb 2026 00:42:04 +0300 Subject: [PATCH] Fix argument redefinition in function --- Lib/ast.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Lib/ast.py b/Lib/ast.py index d9743ba7ab40b1..24ac8c9118dd55 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -316,11 +316,14 @@ def get_docstring(node, clean=True): """ if not isinstance(node, (AsyncFunctionDef, FunctionDef, ClassDef, Module)): raise TypeError("%r can't have docstrings" % node.__class__.__name__) - if not(node.body and isinstance(node.body[0], Expr)): + if not (node.body and isinstance(node.body[0], Expr)): return None - node = node.body[0].value - if isinstance(node, Constant) and isinstance(node.value, str): - text = node.value + checking_node = node.body[0].value + if ( + isinstance(checking_node, Constant) + and isinstance(checking_node.value, str) + ): + text = checking_node.value else: return None if clean: