Skip to content

Commit 2cbbec3

Browse files
committed
Fix file
1 parent bf44395 commit 2cbbec3

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/git_autograder/commit.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,11 @@ def file_change_type(self, file_name: str) -> Optional[str]:
5858
return self.stats.files[file_name]["change_type"]
5959

6060
@contextmanager
61-
def file(
62-
self, file_path: Union[str, os.PathLike[str]]
63-
) -> Iterator[Optional[TextIO]]:
61+
def file(self, file_path: str) -> Iterator[Optional[str]]:
62+
content = None
6463
try:
65-
rel_path = os.fspath(file_path)
66-
file_blob = self.commit.tree / rel_path
67-
yield file_blob.data_stream.read().decode()
64+
file_blob = self.commit.tree / file_path
65+
content = file_blob.data_stream.read().decode("utf-8")
6866
except Exception:
69-
yield None
67+
content = None
68+
yield content

0 commit comments

Comments
 (0)