diff --git a/fvcore/common/checkpoint.py b/fvcore/common/checkpoint.py index 99f1917..5f87a03 100644 --- a/fvcore/common/checkpoint.py +++ b/fvcore/common/checkpoint.py @@ -123,6 +123,7 @@ def save(self, name: str, **kwargs: Any) -> None: assert os.path.basename(save_file) == basename, basename self.logger.info("Saving checkpoint to {}".format(save_file)) with self.path_manager.open(save_file, "wb") as f: + # pyre-fixme[22]: The cast is redundant. torch.save(data, cast(IO[bytes], f)) self.tag_last_checkpoint(basename) @@ -186,8 +187,6 @@ def get_checkpoint_file(self) -> str: # if file doesn't exist, maybe because it has just been # deleted by a separate process return "" - # pyre-fixme[6]: For 2nd argument expected `Union[PathLike[str], str]` but - # got `Union[bytes, str]`. return os.path.join(self.save_dir, last_saved) def get_all_checkpoint_files(self) -> List[str]: @@ -234,7 +233,7 @@ def tag_last_checkpoint(self, last_filename_basename: str) -> None: """ save_file = os.path.join(self.save_dir, "last_checkpoint") with self.path_manager.open(save_file, "w") as f: - f.write(last_filename_basename) # pyre-ignore + f.write(last_filename_basename) def _load_file(self, f: str) -> Dict[str, Any]: """ @@ -249,6 +248,7 @@ def _load_file(self, f: str) -> Dict[str, Any]: to torch.Tensor or numpy arrays. """ with self.path_manager.open(f, "rb") as file: + # pyre-fixme[22]: The cast is redundant. return torch.load(cast(IO[bytes], file), map_location=torch.device("cpu")) def _load_model(self, checkpoint: Any) -> _IncompatibleKeys: diff --git a/io_tests/test_file_io.py b/io_tests/test_file_io.py index 9f47674..6f0f5e7 100644 --- a/io_tests/test_file_io.py +++ b/io_tests/test_file_io.py @@ -197,7 +197,7 @@ def test_open_writes(self) -> None: # HTTPURLHandler does not support writing, only reading. with self.assertRaises(AssertionError): with PathManager.open(self._remote_uri, "w") as f: - f.write("foobar") # pyre-ignore + f.write("foobar") def test_bad_args(self) -> None: with self.assertRaises(NotImplementedError):