diff --git a/torchvision/datasets/dtd.py b/torchvision/datasets/dtd.py index 2d8314346b9..2b10efe94e2 100644 --- a/torchvision/datasets/dtd.py +++ b/torchvision/datasets/dtd.py @@ -1,6 +1,6 @@ import os import pathlib -from typing import Callable, Optional +from typing import Any, Callable, Optional, Tuple import PIL.Image @@ -76,7 +76,7 @@ def __init__( def __len__(self) -> int: return len(self._image_files) - def __getitem__(self, idx): + def __getitem__(self, idx: int) -> Tuple[Any, Any]: image_file, label = self._image_files[idx], self._labels[idx] image = PIL.Image.open(image_file).convert("RGB") diff --git a/torchvision/datasets/fgvc_aircraft.py b/torchvision/datasets/fgvc_aircraft.py index 2e4993361ca..aa705b305d8 100644 --- a/torchvision/datasets/fgvc_aircraft.py +++ b/torchvision/datasets/fgvc_aircraft.py @@ -90,7 +90,7 @@ def __init__( def __len__(self) -> int: return len(self._image_files) - def __getitem__(self, idx) -> Tuple[Any, Any]: + def __getitem__(self, idx: int) -> Tuple[Any, Any]: image_file, label = self._image_files[idx], self._labels[idx] image = PIL.Image.open(image_file).convert("RGB") diff --git a/torchvision/datasets/flowers102.py b/torchvision/datasets/flowers102.py index ad3a6dda0e8..fdaf2ddb4d1 100644 --- a/torchvision/datasets/flowers102.py +++ b/torchvision/datasets/flowers102.py @@ -76,7 +76,7 @@ def __init__( def __len__(self) -> int: return len(self._image_files) - def __getitem__(self, idx) -> Tuple[Any, Any]: + def __getitem__(self, idx: int) -> Tuple[Any, Any]: image_file, label = self._image_files[idx], self._labels[idx] image = PIL.Image.open(image_file).convert("RGB") diff --git a/torchvision/datasets/food101.py b/torchvision/datasets/food101.py index e7d1bd19447..d2557a82736 100644 --- a/torchvision/datasets/food101.py +++ b/torchvision/datasets/food101.py @@ -69,7 +69,7 @@ def __init__( def __len__(self) -> int: return len(self._image_files) - def __getitem__(self, idx) -> Tuple[Any, Any]: + def __getitem__(self, idx: int) -> Tuple[Any, Any]: image_file, label = self._image_files[idx], self._labels[idx] image = PIL.Image.open(image_file).convert("RGB") diff --git a/torchvision/datasets/rendered_sst2.py b/torchvision/datasets/rendered_sst2.py index 89adf8cf8d8..58ea2f9cfe9 100644 --- a/torchvision/datasets/rendered_sst2.py +++ b/torchvision/datasets/rendered_sst2.py @@ -59,7 +59,7 @@ def __init__( def __len__(self) -> int: return len(self._samples) - def __getitem__(self, idx) -> Tuple[Any, Any]: + def __getitem__(self, idx: int) -> Tuple[Any, Any]: image_file, label = self._samples[idx] image = PIL.Image.open(image_file).convert("RGB") diff --git a/torchvision/datasets/sun397.py b/torchvision/datasets/sun397.py index 05cb910dde8..0a1ffef9b98 100644 --- a/torchvision/datasets/sun397.py +++ b/torchvision/datasets/sun397.py @@ -55,7 +55,7 @@ def __init__( def __len__(self) -> int: return len(self._image_files) - def __getitem__(self, idx) -> Tuple[Any, Any]: + def __getitem__(self, idx: int) -> Tuple[Any, Any]: image_file, label = self._image_files[idx], self._labels[idx] image = PIL.Image.open(image_file).convert("RGB")