fix: resolve CI linting errors - remove unused imports and update type annotations
Some checks failed
CI / test (3.10) (push) Has been cancelled
CI / test (3.11) (push) Has been cancelled
CI / test (3.12) (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / build (push) Has been cancelled

This commit is contained in:
2026-02-02 14:39:10 +00:00
parent e52848b7dd
commit 43f5271d7b

View File

@@ -1,7 +1,6 @@
"""Diff parser for unified git diff format."""
import re
from typing import Optional
from gdiffer.models import DiffFile, DiffHunk
@@ -16,6 +15,7 @@ class DiffParser:
self.errors: list[str] = []
def parse(self, diff_content: str) -> list[DiffFile]:
"""Parse diff content and return list of DiffFile objects."""
self.files = []
self.errors = []
@@ -42,7 +42,7 @@ class DiffParser:
i += 1
def _parse_file(self, lines: list[str], start: int) -> Optional[DiffFile]:
def _parse_file(self, lines: list[str], start: int) -> DiffFile | None:
if start >= len(lines):
return None
@@ -120,7 +120,7 @@ class DiffParser:
return file_obj
def _parse_hunk(self, lines: list[str], start: int) -> tuple[Optional[DiffHunk], int]:
def _parse_hunk(self, lines: list[str], start: int) -> tuple[DiffHunk | None, int]:
if start >= len(lines):
return None, 0
@@ -198,6 +198,6 @@ def parse_diff(diff_content: str) -> list[DiffFile]:
def parse_diff_from_file(filepath: str) -> list[DiffFile]:
"""Read a diff file and parse its contents."""
with open(filepath, 'r') as f:
with open(filepath) as f:
content = f.read()
return parse_diff(content)