Skip to content

Commit 4f29bfc

Browse files
generatedunixname1526759334626947facebook-github-bot
authored andcommitted
Remove redundant casts] fbsource/fbcode/vision/fair/fvcore/fvcore/common
Reviewed By: yangdanny97 Differential Revision: D77359407 fbshipit-source-id: 027d5f67345a5bffbc0ee20a0b487143bf667ea5
1 parent b2ac9ab commit 4f29bfc

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

fvcore/common/checkpoint.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import logging
77
import os
88
from collections import defaultdict
9-
from typing import Any, cast, Dict, IO, Iterable, List, NamedTuple, Optional, Tuple
9+
from typing import Any, Dict, Iterable, List, NamedTuple, Optional, Tuple
1010

1111
import numpy as np
1212
import torch
@@ -125,8 +125,7 @@ def save(self, name: str, **kwargs: Any) -> None:
125125
assert os.path.basename(save_file) == basename, basename
126126
self.logger.info("Saving checkpoint to {}".format(save_file))
127127
with self.path_manager.open(save_file, "wb") as f:
128-
# pyre-fixme[22]: The cast is redundant.
129-
torch.save(data, cast(IO[bytes], f))
128+
torch.save(data, f)
130129
self.tag_last_checkpoint(basename)
131130

132131
def load(
@@ -250,8 +249,7 @@ def _load_file(self, f: str) -> Dict[str, Any]:
250249
to torch.Tensor or numpy arrays.
251250
"""
252251
with self.path_manager.open(f, "rb") as file:
253-
# pyre-fixme[22]: The cast is redundant.
254-
return torch.load(cast(IO[bytes], file), map_location=torch.device("cpu"))
252+
return torch.load(file, map_location=torch.device("cpu"))
255253

256254
def _load_model(self, checkpoint: Any) -> _IncompatibleKeys:
257255
"""

0 commit comments

Comments
 (0)