Skip to content

Commit c82219a

Browse files
committed
Fix type hints in Places365 dataset
1 parent c6052ed commit c82219a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

torchvision/datasets/places365.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
from os import path
33
from pathlib import Path
4-
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
4+
from typing import Any, Callable, cast, Dict, List, Optional, Tuple, Union
55
from urllib.parse import urljoin
66

77
from .folder import default_loader
@@ -127,9 +127,10 @@ def process(line: str) -> Tuple[str, int]:
127127

128128
return sorted(class_to_idx.keys()), class_to_idx
129129

130-
def load_file_list(self, download: bool = True) -> Tuple[List[Tuple[str, int]], List[int]]:
131-
def process(line: str, sep="/") -> Tuple[str, int]:
130+
def load_file_list(self, download: bool = True) -> Tuple[List[Tuple[str, int | None]], List[int | None]]:
131+
def process(line: str, sep="/") -> Tuple[str, int | None]:
132132
image, idx = (line.split() + [None])[:2]
133+
image = cast(str, image)
133134
idx = int(idx) if idx is not None else None
134135
return path.join(self.images_dir, image.lstrip(sep).replace(sep, os.sep)), idx
135136

0 commit comments

Comments
 (0)