We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent bf44395 commit 2cbbec3Copy full SHA for 2cbbec3
src/git_autograder/commit.py
@@ -58,12 +58,11 @@ def file_change_type(self, file_name: str) -> Optional[str]:
58
return self.stats.files[file_name]["change_type"]
59
60
@contextmanager
61
- def file(
62
- self, file_path: Union[str, os.PathLike[str]]
63
- ) -> Iterator[Optional[TextIO]]:
+ def file(self, file_path: str) -> Iterator[Optional[str]]:
+ content = None
64
try:
65
- rel_path = os.fspath(file_path)
66
- file_blob = self.commit.tree / rel_path
67
- yield file_blob.data_stream.read().decode()
+ file_blob = self.commit.tree / file_path
+ content = file_blob.data_stream.read().decode("utf-8")
68
except Exception:
69
- yield None
+ yield content
0 commit comments