Skip to content

Commit 3299f88

Browse files
committed
refactors structure -> analyzed_classes
1 parent e0d5532 commit 3299f88

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

scripts/microgenerator/generate.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def visit_ClassDef(self, node: ast.ClassDef) -> None:
162162
type_str = self._get_type_str(item.annotation)
163163
class_info["attributes"].append({"name": attr_name, "type": type_str})
164164

165-
self.structure.append(class_info)
165+
self.analyzed_classes.append(class_info)
166166
self._current_class_info = class_info
167167
self._depth += 1
168168
self.generic_visit(node)
@@ -278,7 +278,7 @@ def parse_code(code: str) -> tuple[List[Dict[str, Any]], set[str], set[str]]:
278278
tree = ast.parse(code)
279279
analyzer = CodeAnalyzer()
280280
analyzer.visit(tree)
281-
return analyzer.structure, analyzer.imports, analyzer.types
281+
return analyzer.analyzed_classes, analyzer.imports, analyzer.types
282282

283283

284284
def parse_file(file_path: str) -> tuple[List[Dict[str, Any]], set[str], set[str]]:
@@ -330,10 +330,10 @@ def list_code_objects(
330330
all_class_keys = []
331331

332332
def process_structure(
333-
structure: List[Dict[str, Any]], file_name: str | None = None
333+
analyzed_classes: List[Dict[str, Any]], file_name: str | None = None
334334
):
335335
"""Populates the results dictionary from the parsed AST structure."""
336-
for class_info in structure:
336+
for class_info in analyzed_classes:
337337
key = class_info["class_name"]
338338
if file_name:
339339
key = f"{key} (in {file_name})"
@@ -359,13 +359,13 @@ def process_structure(
359359

360360
# Determine if the path is a file or directory and process accordingly
361361
if os.path.isfile(path) and path.endswith(".py"):
362-
structure, _, _ = parse_file(path)
363-
process_structure(structure)
362+
analyzed_classes, _, _ = parse_file(path)
363+
process_structure(analyzed_classes)
364364
elif os.path.isdir(path):
365365
# This assumes `utils.walk_codebase` is defined elsewhere.
366366
for file_path in utils.walk_codebase(path):
367-
structure, _, _ = parse_file(file_path)
368-
process_structure(structure, file_name=os.path.basename(file_path))
367+
analyzed_classes, _, _ = parse_file(file_path)
368+
process_structure(analyzed_classes, file_name=os.path.basename(file_path))
369369

370370
# Return the data in the desired format based on the flags
371371
if not show_methods and not show_attributes:
@@ -417,11 +417,11 @@ def _build_request_arg_schema(
417417
module_name = os.path.splitext(relative_path)[0].replace(os.path.sep, ".")
418418

419419
try:
420-
structure, _, _ = parse_file(file_path)
421-
if not structure:
420+
analyzed_classes, _, _ = parse_file(file_path)
421+
if not analyzed_classes:
422422
continue
423423

424-
for class_info in structure:
424+
for class_info in analyzed_classes:
425425
class_name = class_info.get("class_name", "Unknown")
426426
if class_name.endswith("Request"):
427427
full_class_name = f"{module_name}.{class_name}"
@@ -449,11 +449,11 @@ def _process_service_clients(
449449
if "/services/" not in file_path:
450450
continue
451451

452-
structure, imports, types = parse_file(file_path)
452+
analyzed_classes, imports, types = parse_file(file_path)
453453
all_imports.update(imports)
454454
all_types.update(types)
455455

456-
for class_info in structure:
456+
for class_info in analyzed_classes:
457457
class_name = class_info["class_name"]
458458
if not _should_include_class(class_name, class_filters):
459459
continue

0 commit comments

Comments
 (0)