Skip to content

Commit bec73a7

Browse files
committed
Fix ast.walk missing import statements with renames
1 parent 89c58ba commit bec73a7

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

src/sasctl/pzmm/write_json_files.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,15 +1144,12 @@ def find_imports(file_path):
11441144

11451145
# Walk through each node in the ast to find import calls
11461146
for node in ast.walk(tree):
1147-
# Determine parent module for from * import * calls
1147+
# Determine parent module for `from * import *` calls
11481148
if isinstance(node, ast.ImportFrom):
1149-
for name in node.names:
1150-
if not name.asname:
1151-
modules.append(node.module)
1149+
modules.append(node.module)
11521150
elif isinstance(node, ast.Import):
11531151
for name in node.names:
1154-
if not node.names[0].asname:
1155-
modules.append(node.names[0].name)
1152+
modules.append(name.name)
11561153

11571154
modules = list(set(modules))
11581155
try:

0 commit comments

Comments
 (0)