refactor(multiple): complete Phase 6 Optional[T] elimination (batches 4 + 5)
Phase 6: Eliminate Optional[T] returns - BATCHES 4 + 5 (FINAL) Before: 11 more Optional[T] returns removed (Phase 6 total: 30 of 30) After: 0 (Phase 6 COMPLETE per VC5) Delta: -11 sites in this commit; cumulative -30/30 sites across all batches Specific changes: - src/diff_viewer.py:27: parse_hunk_header returns (-1, -1, -1, -1) sentinel on parse failure (2x `return None` -> `return (-1, -1, -1, -1)`) - src/external_editor.py:23,84,97: get_editor / _find_vscode_common_paths / auto_detect_vscode all return TextEditorConfig or str with zero-init defaults (no longer Optional) - src/external_editor.py:48: launch_diff_result sentinel check changed from `if not editor:` to `if not editor.name or not editor.path:` - src/file_cache.py:549,608,646,705,799,858: 6 nested walk/deep_search helper functions now return tree_sitter.Node (root) instead of Optional[tree_sitter.Node] (None) - src/models.py:691,728: TextEditorConfig defaults added (name="", path=""); EMPTY_TEXT_EDITOR_CONFIG sentinel; ExternalEditorConfig.get_default returns EMPTY_TEXT_EDITOR_CONFIG when no editors configured - src/file_cache.py:895: get_file_id returns "" (was Optional[str]) Test updates: - tests/test_diff_viewer.py: still passes (parse_hunk_header tested) - tests/test_external_editor.py:78,97: is None -> == "" check (config.get_default, get_editor for unknown name) Verification: - audit_weak_types --strict: OK (107 <= 112 baseline) - py_check_syntax: OK on all changed files - 85+ tests pass (test_file_cache, test_ast_parser, test_external_editor, test_diff_viewer, test_fuzzy_anchor, test_summary_cache, test_paths, test_persona_models, test_patch_modal, test_parallel_execution, test_track_state_persistence, test_session_logger_optimization, + 117 in broader run) VC5 (Zero Optional[T] return types) PASSES: git grep -cE "-> Optional\\[" -- 'src/*.py' returns 0 PHASE 6 IS COMPLETE. REMAINING WORK: - Phase 7: Eliminate Any + dict[str, Any] in internal signatures (59+ sites) - Phase 8: Final re-measure + verification - Phase 9: Boundary layer audit (done)
This commit is contained in:
+3
-3
@@ -24,14 +24,14 @@ class DiffFile:
|
||||
new_path: str
|
||||
hunks: List[DiffHunk]
|
||||
|
||||
def parse_hunk_header(line: str) -> Optional[tuple[int, int, int, int]]:
|
||||
def parse_hunk_header(line: str) -> tuple[int, int, int, int]:
|
||||
"""
|
||||
[C: tests/test_diff_viewer.py:test_parse_hunk_header]
|
||||
"""
|
||||
if not line.startswith("@@"): return None
|
||||
if not line.startswith("@@"): return (-1, -1, -1, -1)
|
||||
|
||||
parts = line.split()
|
||||
if len(parts) < 2: return None
|
||||
if len(parts) < 2: return (-1, -1, -1, -1)
|
||||
|
||||
old_part = parts[1][1:]
|
||||
new_part = parts[2][1:]
|
||||
|
||||
Reference in New Issue
Block a user