summaryrefslogtreecommitdiffstats
path: root/docs/utils.py
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2022-06-14 23:02:42 +0200
committerGravatar Numerlor <[email protected]>2022-06-15 00:02:08 +0200
commitc51a2d7e39cdc881efe65cceb5a82649db08d92d (patch)
treea340c85228e12c6ff1ff5803b422f341462aca2d /docs/utils.py
parentCheck assignments nested in ifs when searching for symbol definition (diff)
Only append ids from Name nodes
Diffstat (limited to 'docs/utils.py')
-rw-r--r--docs/utils.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/docs/utils.py b/docs/utils.py
index 5be5292b..a4662ba4 100644
--- a/docs/utils.py
+++ b/docs/utils.py
@@ -99,6 +99,7 @@ def linkcode_resolve(repo_link: str, domain: str, info: dict[str, str]) -> typin
class NodeWithBody(typing.Protocol):
"""An AST node with the body attribute."""
+
body: list[ast.AST]
@@ -113,9 +114,10 @@ def _global_assign_pos(ast_: NodeWithBody, name: str) -> typing.Union[tuple[int,
names = []
for target in ast_obj.targets:
if isinstance(target, ast.Tuple):
- names.extend([name.id for name in target.elts])
+ names.extend([name.id for name in target.elts if isinstance(name, ast.Name)])
else:
- names.append(target.id)
+ if isinstance(target, ast.Name):
+ names.append(target.id)
if name in names:
return ast_obj.lineno, ast_obj.end_lineno