Skip to content

Commit 97e1722

Browse files
Fix additional type checking issues
- Update get_file return type to allow None in repo_operator.py - Add type checking for decoded_filepath before decode operation - Handle both bytes and string types from codecs.escape_decode This reduces type checking diagnostics from 30 to 28.
1 parent 1f89699 commit 97e1722

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/codegen/git/repo_operator/repo_operator.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ def emptydir(self, path: str) -> None:
566566
if os.path.isfile(file_path):
567567
os.remove(file_path)
568568

569-
def get_file(self, path: str) -> str:
569+
def get_file(self, path: str) -> str | None:
570570
"""Returns the contents of a file"""
571571
file_path = self.abspath(path)
572572
try:
@@ -621,7 +621,10 @@ def get_filepaths_for_repo(self, ignore_list):
621621
decoded_filepath, _ = codecs.escape_decode(raw_filepath)
622622

623623
# Step 4: Decode those bytes as UTF-8 to get the actual Unicode text
624-
filepath = decoded_filepath.decode("utf-8")
624+
if isinstance(decoded_filepath, bytes):
625+
filepath = decoded_filepath.decode("utf-8")
626+
else:
627+
filepath = str(decoded_filepath)
625628

626629
# Step 5: Replace the original filepath with the decoded filepath
627630
filepaths[i] = filepath

0 commit comments

Comments
 (0)