chore(legacy): Remove gui_legacy.py and refactor all tests to use gui_2.py
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
"""
|
||||
Type hint applicator for gui_2.py and gui_legacy.py.
|
||||
Type hint applicator for gui_2.py.
|
||||
Does a single-pass AST-guided line edit to add type annotations.
|
||||
No dependency on mcp_client — operates directly on file lines.
|
||||
|
||||
@@ -182,50 +182,6 @@ GUI2_MANUAL_SIGS: list[tuple[str, str]] = [
|
||||
r'def _render_ticket_dag_node(self, ticket: Ticket, tickets_by_id: dict[str, Ticket], children_map: dict[str, list[str]], rendered: set[str]) -> None:'),
|
||||
]
|
||||
|
||||
# ============================================================
|
||||
# gui_legacy.py manual signatures (Tier 3 items)
|
||||
# ============================================================
|
||||
LEGACY_MANUAL_SIGS: list[tuple[str, str]] = [
|
||||
(r'def _add_kv_row\(parent: str, key: str, val, val_color=None\):',
|
||||
r'def _add_kv_row(parent: str, key: str, val: Any, val_color: tuple[int, int, int] | None = None) -> None:'),
|
||||
(r'def _make_remove_file_cb\(self, idx: int\):',
|
||||
r'def _make_remove_file_cb(self, idx: int) -> Callable:'),
|
||||
(r'def _make_remove_shot_cb\(self, idx: int\):',
|
||||
r'def _make_remove_shot_cb(self, idx: int) -> Callable:'),
|
||||
(r'def _make_remove_project_cb\(self, idx: int\):',
|
||||
r'def _make_remove_project_cb(self, idx: int) -> Callable:'),
|
||||
(r'def _make_switch_project_cb\(self, path: str\):',
|
||||
r'def _make_switch_project_cb(self, path: str) -> Callable:'),
|
||||
(r'def cb_word_wrap_toggled\(self, sender=None, app_data=None\):',
|
||||
r'def cb_word_wrap_toggled(self, sender: Any = None, app_data: Any = None) -> None:'),
|
||||
(r'def cb_provider_changed\(self, sender, app_data\):',
|
||||
r'def cb_provider_changed(self, sender: Any, app_data: Any) -> None:'),
|
||||
(r'def cb_model_changed\(self, sender, app_data\):',
|
||||
r'def cb_model_changed(self, sender: Any, app_data: Any) -> None:'),
|
||||
(r'def _cb_new_project_automated\(self, path\):',
|
||||
r'def _cb_new_project_automated(self, path: str) -> None:'),
|
||||
(r'def cb_disc_switch\(self, sender, app_data\):',
|
||||
r'def cb_disc_switch(self, sender: Any, app_data: Any) -> None:'),
|
||||
(r'def _make_disc_remove_role_cb\(self, idx: int\):',
|
||||
r'def _make_disc_remove_role_cb(self, idx: int) -> Callable:'),
|
||||
(r'def _cb_toggle_read\(self, sender, app_data, user_data\):',
|
||||
r'def _cb_toggle_read(self, sender: Any, app_data: Any, user_data: Any) -> None:'),
|
||||
(r'def _make_disc_role_cb\(self, idx: int\):',
|
||||
r'def _make_disc_role_cb(self, idx: int) -> Callable:'),
|
||||
(r'def _make_disc_content_cb\(self, idx: int\):',
|
||||
r'def _make_disc_content_cb(self, idx: int) -> Callable:'),
|
||||
(r'def _make_disc_insert_cb\(self, idx: int\):',
|
||||
r'def _make_disc_insert_cb(self, idx: int) -> Callable:'),
|
||||
(r'def _make_disc_remove_cb\(self, idx: int\):',
|
||||
r'def _make_disc_remove_cb(self, idx: int) -> Callable:'),
|
||||
(r'def _make_disc_toggle_cb\(self, idx: int\):',
|
||||
r'def _make_disc_toggle_cb(self, idx: int) -> Callable:'),
|
||||
(r'def cb_palette_changed\(self, sender, app_data\):',
|
||||
r'def cb_palette_changed(self, sender: Any, app_data: Any) -> None:'),
|
||||
(r'def cb_scale_changed\(self, sender, app_data\):',
|
||||
r'def cb_scale_changed(self, sender: Any, app_data: Any) -> None:'),
|
||||
]
|
||||
|
||||
# ============================================================
|
||||
# gui_2.py variable type annotations
|
||||
# ============================================================
|
||||
@@ -252,54 +208,26 @@ GUI2_VAR_REPLACEMENTS: list[tuple[str, str]] = [
|
||||
(r'^AGENT_TOOL_NAMES = ', 'AGENT_TOOL_NAMES: list[str] = '),
|
||||
]
|
||||
|
||||
# ============================================================
|
||||
# gui_legacy.py variable type annotations
|
||||
# ============================================================
|
||||
LEGACY_VAR_REPLACEMENTS: list[tuple[str, str]] = [
|
||||
(r'^CONFIG_PATH = ', 'CONFIG_PATH: Path = '),
|
||||
(r'^PROVIDERS = ', 'PROVIDERS: list[str] = '),
|
||||
(r'^COMMS_CLAMP_CHARS = ', 'COMMS_CLAMP_CHARS: int = '),
|
||||
(r'^_DIR_COLORS = \{', '_DIR_COLORS: dict[str, tuple[int, int, int]] = {'),
|
||||
(r'^_KIND_COLORS = \{', '_KIND_COLORS: dict[str, tuple[int, int, int]] = {'),
|
||||
(r'^_HEAVY_KEYS = ', '_HEAVY_KEYS: set[str] = '),
|
||||
(r'^_LABEL_COLOR = ', '_LABEL_COLOR: tuple[int, int, int] = '),
|
||||
(r'^_VALUE_COLOR = ', '_VALUE_COLOR: tuple[int, int, int] = '),
|
||||
(r'^_KEY_COLOR = ', '_KEY_COLOR: tuple[int, int, int] = '),
|
||||
(r'^_NUM_COLOR = ', '_NUM_COLOR: tuple[int, int, int] = '),
|
||||
(r'^_SUBHDR_COLOR = ', '_SUBHDR_COLOR: tuple[int, int, int] = '),
|
||||
(r'^_KIND_RENDERERS = \{', '_KIND_RENDERERS: dict[str, Callable] = {'),
|
||||
(r'^DISC_ROLES = ', 'DISC_ROLES: list[str] = '),
|
||||
(r'^ _next_id = ', ' _next_id: int = '),
|
||||
]
|
||||
|
||||
if __name__ == "__main__":
|
||||
print("=== Phase A: Auto-apply -> None (single-pass AST) ===")
|
||||
n = apply_return_none_single_pass("gui_2.py")
|
||||
stats["auto_none"] += n
|
||||
print(f" gui_2.py: {n} applied")
|
||||
n = apply_return_none_single_pass("gui_legacy.py")
|
||||
stats["auto_none"] += n
|
||||
print(f" gui_legacy.py: {n} applied")
|
||||
# Verify syntax after Phase A
|
||||
for f in ["gui_2.py", "gui_legacy.py"]:
|
||||
r = verify_syntax(f)
|
||||
if "Error" in r:
|
||||
print(f" ABORT: {r}")
|
||||
sys.exit(1)
|
||||
r = verify_syntax("gui_2.py")
|
||||
if "Error" in r:
|
||||
print(f" ABORT: {r}")
|
||||
sys.exit(1)
|
||||
print(" Syntax OK after Phase A")
|
||||
print("\n=== Phase B: Manual signatures (regex) ===")
|
||||
n = apply_manual_sigs("gui_2.py", GUI2_MANUAL_SIGS)
|
||||
stats["manual_sig"] += n
|
||||
print(f" gui_2.py: {n} applied")
|
||||
n = apply_manual_sigs("gui_legacy.py", LEGACY_MANUAL_SIGS)
|
||||
stats["manual_sig"] += n
|
||||
print(f" gui_legacy.py: {n} applied")
|
||||
# Verify syntax after Phase B
|
||||
for f in ["gui_2.py", "gui_legacy.py"]:
|
||||
r = verify_syntax(f)
|
||||
if "Error" in r:
|
||||
print(f" ABORT: {r}")
|
||||
sys.exit(1)
|
||||
r = verify_syntax("gui_2.py")
|
||||
if "Error" in r:
|
||||
print(f" ABORT: {r}")
|
||||
sys.exit(1)
|
||||
print(" Syntax OK after Phase B")
|
||||
print("\n=== Phase C: Variable annotations (regex) ===")
|
||||
# Use re.MULTILINE so ^ matches line starts
|
||||
@@ -322,16 +250,10 @@ if __name__ == "__main__":
|
||||
n = apply_var_replacements_m("gui_2.py", GUI2_VAR_REPLACEMENTS)
|
||||
stats["vars"] += n
|
||||
print(f" gui_2.py: {n} applied")
|
||||
n = apply_var_replacements_m("gui_legacy.py", LEGACY_VAR_REPLACEMENTS)
|
||||
stats["vars"] += n
|
||||
print(f" gui_legacy.py: {n} applied")
|
||||
print("\n=== Final Syntax Verification ===")
|
||||
all_ok = True
|
||||
for f in ["gui_2.py", "gui_legacy.py"]:
|
||||
r = verify_syntax(f)
|
||||
print(f" {f}: {r}")
|
||||
if "Error" in r:
|
||||
all_ok = False
|
||||
r = verify_syntax("gui_2.py")
|
||||
print(f" gui_2.py: {r}")
|
||||
all_ok = "Error" not in r
|
||||
print("\n=== Summary ===")
|
||||
print(f" Auto -> None: {stats['auto_none']}")
|
||||
print(f" Manual sigs: {stats['manual_sig']}")
|
||||
|
||||
Reference in New Issue
Block a user