Skip to content

Commit d1be85b

Browse files
committed
fix: fix type annotation again.
1 parent 6dabc65 commit d1be85b

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

torchvision/datasets/flowers102.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050
transform: Optional[Callable] = None,
5151
target_transform: Optional[Callable] = None,
5252
download: bool = False,
53-
loader: Callable[[Union[str, pathlib.Path]], Any] = default_loader,
53+
loader: Callable[[Union[str, Path]], Any] = default_loader,
5454
) -> None:
5555
super().__init__(root, transform=transform, target_transform=target_transform)
5656
self._split = verify_str_arg(split, "split", ("train", "val", "test"))

torchvision/datasets/folder.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,15 @@ def __len__(self) -> int:
257257
IMG_EXTENSIONS = (".jpg", ".jpeg", ".png", ".ppm", ".bmp", ".pgm", ".tif", ".tiff", ".webp")
258258

259259

260-
def pil_loader(path: str | Path) -> Image.Image:
260+
def pil_loader(path: Union[str, Path]) -> Image.Image:
261261
# open path as file to avoid ResourceWarning (https://github.com/python-pillow/Pillow/issues/835)
262262
with open(path, "rb") as f:
263263
img = Image.open(f)
264264
return img.convert("RGB")
265265

266266

267267
# TODO: specify the return type
268-
def accimage_loader(path: str | Path) -> Any:
268+
def accimage_loader(path: Union[str, Path]) -> Any:
269269
import accimage
270270

271271
try:
@@ -275,7 +275,7 @@ def accimage_loader(path: str | Path) -> Any:
275275
return pil_loader(path)
276276

277277

278-
def default_loader(path: str | Path) -> Any:
278+
def default_loader(path: Union[str, Path]) -> Any:
279279
from torchvision import get_image_backend
280280

281281
if get_image_backend() == "accimage":

torchvision/datasets/food101.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(
4242
transform: Optional[Callable] = None,
4343
target_transform: Optional[Callable] = None,
4444
download: bool = False,
45-
loader: Callable[[Union[str, pathlib.Path]], Any] = default_loader,
45+
loader: Callable[[Union[str, Path]], Any] = default_loader,
4646
) -> None:
4747
super().__init__(root, transform=transform, target_transform=target_transform)
4848
self._split = verify_str_arg(split, "split", ("train", "test"))

torchvision/datasets/sun397.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(
3535
transform: Optional[Callable] = None,
3636
target_transform: Optional[Callable] = None,
3737
download: bool = False,
38-
loader: Callable[[Union[str, pathlib.Path]], Any] = default_loader,
38+
loader: Callable[[Union[str, Path]], Any] = default_loader,
3939
) -> None:
4040
super().__init__(root, transform=transform, target_transform=target_transform)
4141
self._data_dir = Path(self.root) / "SUN397"

0 commit comments

Comments
 (0)