From 7eb63a5d8786b9b5e95c62d520782ecba289d15a Mon Sep 17 00:00:00 2001 From: pyob-bot Date: Fri, 12 Jun 2026 02:53:43 +0000 Subject: [PATCH 1/4] Refactor: Simplify XML replacement logic and remove redundant indentation handling --- src/pyob/xml_mixin.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/pyob/xml_mixin.py b/src/pyob/xml_mixin.py index 303746c..eb70fc4 100644 --- a/src/pyob/xml_mixin.py +++ b/src/pyob/xml_mixin.py @@ -314,20 +314,13 @@ def _attempt_line_by_line_match( code_lines = source.splitlines() for i in range(len(code_lines) - len(search_lines) + 1): match = True - for j, sline in enumerate(search_lines_stripped): - if sline not in code_lines[i + j].strip(): + for j, sline in enumerate(search_lines): + if sline.strip() not in code_lines[i + j].strip(): match = False break if match: - # Apply indentation fix to replacement lines - fixed_replace = self._fix_replace_indentation( - "\n".join(code_lines[i : i + len(search_lines)]), - "\n".join(replace_lines), - ) new_code_lines = ( - code_lines[:i] - + fixed_replace.splitlines() - + code_lines[i + len(search_lines) :] + code_lines[:i] + replace_lines + code_lines[i + len(search_lines) :] ) new_code = "\n".join(new_code_lines) if not new_code.endswith("\n") and source.endswith("\n"): From 8d4e8abb543c5ae6bcdb1c70c50d95473f7797a0 Mon Sep 17 00:00:00 2001 From: pyob-bot Date: Fri, 12 Jun 2026 02:59:58 +0000 Subject: [PATCH 2/4] Fix: Suppress type checking errors for unix-specific imports --- src/pyob/core_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pyob/core_utils.py b/src/pyob/core_utils.py index dd4e744..27cf59b 100644 --- a/src/pyob/core_utils.py +++ b/src/pyob/core_utils.py @@ -288,8 +288,8 @@ def _win32_input(self, start_time: float, timeout: int) -> str: time.sleep(0.1) def _unix_input(self, start_time: float, timeout: int) -> str: - import termios - import tty + import termios # type: ignore + import tty # type: ignore input_str: str = "" fd = sys.stdin.fileno() From d3000bb1ec41dffc548c4e50497aec30da262562 Mon Sep 17 00:00:00 2001 From: pyob-bot Date: Fri, 12 Jun 2026 03:03:02 +0000 Subject: [PATCH 3/4] Refactor: Add type hints to CodeParser AST visitor methods --- src/pyob/pyob_code_parser.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/pyob/pyob_code_parser.py b/src/pyob/pyob_code_parser.py index 8475074..662d2c9 100644 --- a/src/pyob/pyob_code_parser.py +++ b/src/pyob/pyob_code_parser.py @@ -37,13 +37,13 @@ def visit_Import(self, node: ast.Import) -> None: except Exception: pass - def visit_ImportFrom(self, node): + def visit_ImportFrom(self, node: ast.ImportFrom) -> None: try: self.imports.append(ast.unparse(node)) except Exception: pass - def visit_ClassDef(self, node): + def visit_ClassDef(self, node: ast.ClassDef) -> None: self.classes.append(f"class {node.name}") old_class = self.current_class self.current_class = node.name @@ -51,13 +51,15 @@ def visit_ClassDef(self, node): self.visit(child) self.current_class = old_class - def visit_FunctionDef(self, node): + def visit_FunctionDef(self, node: ast.FunctionDef) -> None: self.handle_function(node) - def visit_AsyncFunctionDef(self, node): + def visit_AsyncFunctionDef(self, node: ast.AsyncFunctionDef) -> None: self.handle_function(node) - def handle_function(self, node): + def handle_function( + self, node: ast.FunctionDef | ast.AsyncFunctionDef + ) -> None: args = [] for arg in node.args.args: if self.current_class and arg.arg == "self": From a714a5be8903d7e2b3229c85494afa40b3b8c22a Mon Sep 17 00:00:00 2001 From: pyob-bot Date: Fri, 12 Jun 2026 03:06:02 +0000 Subject: [PATCH 4/4] Fix: Filter noise and refine regex in AST reference extraction --- src/pyob/entrance.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pyob/entrance.py b/src/pyob/entrance.py index 13b77ed..dae469e 100644 --- a/src/pyob/entrance.py +++ b/src/pyob/entrance.py @@ -535,11 +535,12 @@ def update_ledger_for_file(self, rel_path: str, code: str): elif isinstance(n.func, ast.Attribute): potential_refs.add(n.func.attr) elif isinstance(n, ast.Name) and isinstance(n.ctx, ast.Load): - potential_refs.add(n.id) + if n.id not in ["self", "None", "True", "False"]: + potential_refs.add(n.id) except Exception as e: logger.warning(f"Failed to parse Python AST for {rel_path}: {e}") potential_refs.update( - re.findall(r"\b[a-zA-Z_][a-zA-Z0-9_]{3,}\b", code) + re.findall(r"\b[a-zA-Z_][a-zA-Z0-9_]{4,}\b", code) ) elif ext in [".js", ".ts"]: defs = re.findall(