Private
Public Access
refactor(src): Phase 10.2 batch 2 - outline_tool Result[T] migration
Migrates 3 sites in src/outline_tool.py: 1. L49 (outline body) - the ast.parse SyntaxError handler. outline() now returns Result[str]. On SyntaxError, the data is the formatted error string (preserved for backwards-compat with callers that read the formatted string), and the errors list has the ErrorInfo. 2. L90 (walk ast.unparse for returns) - was except ...: pass. Now appends ErrorInfo to enclosing parse_errors list. 3. L109 (walk ast.unparse for ImGui context) - same. outline() returns Result(data='\n'.join(output), errors=parse_errors). get_outline() also returns Result[str]. Tests updated to check result.ok and use result.data.
This commit is contained in:
@@ -8,14 +8,15 @@ def test_code_outliner_type_hints():
|
||||
class Test:
|
||||
def my_method(self, x: int) -> str:
|
||||
return "hello"
|
||||
|
||||
|
||||
def my_func(a: bool) -> None:
|
||||
pass
|
||||
"""
|
||||
outliner = CodeOutliner()
|
||||
result = outliner.outline(code)
|
||||
assert "[Method] my_method -> str (Lines 3-4)" in result
|
||||
assert "[Func] my_func -> None (Lines 6-7)" in result
|
||||
assert result.ok, f"outline failed: {result.errors}"
|
||||
assert "[Method] my_method -> str (Lines 3-4)" in result.data
|
||||
assert "[Func] my_func -> None (Lines 6-7)" in result.data
|
||||
|
||||
def test_code_outliner_imgui_scopes():
|
||||
code = """
|
||||
@@ -27,8 +28,9 @@ def render_gui() -> None:
|
||||
"""
|
||||
outliner = CodeOutliner()
|
||||
result = outliner.outline(code)
|
||||
assert "[ImGui Scope] imscope.window('My Window') (Lines 3-6)" in result
|
||||
assert "[ImGui Scope] imscope.child('My Child') (Lines 5-6)" in result
|
||||
assert result.ok, f"outline failed: {result.errors}"
|
||||
assert "[ImGui Scope] imscope.window('My Window') (Lines 3-6)" in result.data
|
||||
assert "[ImGui Scope] imscope.child('My Child') (Lines 5-6)" in result.data
|
||||
|
||||
def test_code_outliner_nested_ifs():
|
||||
code = """
|
||||
@@ -39,4 +41,5 @@ def render_gui() -> None:
|
||||
"""
|
||||
outliner = CodeOutliner()
|
||||
result = outliner.outline(code)
|
||||
assert "[ImGui Scope] imscope.window('My Window') (Lines 4-5)" in result
|
||||
assert result.ok, f"outline failed: {result.errors}"
|
||||
assert "[ImGui Scope] imscope.window('My Window') (Lines 4-5)" in result.data
|
||||
|
||||
Reference in New Issue
Block a user