Skip to content

Commit ee93c07

Browse files
committed
Add missing None type hint to init functions
1 parent 6bea4ef commit ee93c07

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+128
-128
lines changed

torchvision/datasets/_optical_flow.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class FlowDataset(ABC, VisionDataset):
2828
# and it's up to whatever consumes the dataset to decide what valid_flow_mask should be.
2929
_has_builtin_flow_mask = False
3030

31-
def __init__(self, root, transforms=None):
31+
def __init__(self, root, transforms=None) -> None:
3232

3333
super().__init__(root=root)
3434
self.transforms = transforms
@@ -118,7 +118,7 @@ class Sintel(FlowDataset):
118118
return a built-in valid mask, such as :class:`~torchvision.datasets.KittiFlow`.
119119
"""
120120

121-
def __init__(self, root, split="train", pass_name="clean", transforms=None):
121+
def __init__(self, root, split="train", pass_name="clean", transforms=None) -> None:
122122
super().__init__(root=root, transforms=transforms)
123123

124124
verify_str_arg(split, "split", valid_values=("train", "test"))
@@ -180,7 +180,7 @@ class KittiFlow(FlowDataset):
180180

181181
_has_builtin_flow_mask = True
182182

183-
def __init__(self, root, split="train", transforms=None):
183+
def __init__(self, root, split="train", transforms=None) -> None:
184184
super().__init__(root=root, transforms=transforms)
185185

186186
verify_str_arg(split, "split", valid_values=("train", "test"))
@@ -245,7 +245,7 @@ class FlyingChairs(FlowDataset):
245245
return a built-in valid mask, such as :class:`~torchvision.datasets.KittiFlow`.
246246
"""
247247

248-
def __init__(self, root, split="train", transforms=None):
248+
def __init__(self, root, split="train", transforms=None) -> None:
249249
super().__init__(root=root, transforms=transforms)
250250

251251
verify_str_arg(split, "split", valid_values=("train", "val"))
@@ -316,7 +316,7 @@ class FlyingThings3D(FlowDataset):
316316
return a built-in valid mask, such as :class:`~torchvision.datasets.KittiFlow`.
317317
"""
318318

319-
def __init__(self, root, split="train", pass_name="clean", camera="left", transforms=None):
319+
def __init__(self, root, split="train", pass_name="clean", camera="left", transforms=None) -> None:
320320
super().__init__(root=root, transforms=transforms)
321321

322322
verify_str_arg(split, "split", valid_values=("train", "test"))
@@ -401,7 +401,7 @@ class HD1K(FlowDataset):
401401

402402
_has_builtin_flow_mask = True
403403

404-
def __init__(self, root, split="train", transforms=None):
404+
def __init__(self, root, split="train", transforms=None) -> None:
405405
super().__init__(root=root, transforms=transforms)
406406

407407
verify_str_arg(split, "split", valid_values=("train", "test"))

torchvision/datasets/_stereo_matching.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class StereoMatchingDataset(ABC, VisionDataset):
2020

2121
_has_built_in_disparity_mask = False
2222

23-
def __init__(self, root: str, transforms: Optional[Callable] = None):
23+
def __init__(self, root: str, transforms: Optional[Callable] = None) -> None:
2424
"""
2525
Args:
2626
root(str): Root directory of the dataset.
@@ -152,7 +152,7 @@ class CarlaStereo(StereoMatchingDataset):
152152
transforms (callable, optional): A function/transform that takes in a sample and returns a transformed version.
153153
"""
154154

155-
def __init__(self, root: str, transforms: Optional[Callable] = None):
155+
def __init__(self, root: str, transforms: Optional[Callable] = None) -> None:
156156
super().__init__(root, transforms)
157157

158158
root = Path(root) / "carla-highres"
@@ -229,7 +229,7 @@ class Kitti2012Stereo(StereoMatchingDataset):
229229

230230
_has_built_in_disparity_mask = True
231231

232-
def __init__(self, root: str, split: str = "train", transforms: Optional[Callable] = None):
232+
def __init__(self, root: str, split: str = "train", transforms: Optional[Callable] = None) -> None:
233233
super().__init__(root, transforms)
234234

235235
verify_str_arg(split, "split", valid_values=("train", "test"))
@@ -317,7 +317,7 @@ class Kitti2015Stereo(StereoMatchingDataset):
317317

318318
_has_built_in_disparity_mask = True
319319

320-
def __init__(self, root: str, split: str = "train", transforms: Optional[Callable] = None):
320+
def __init__(self, root: str, split: str = "train", transforms: Optional[Callable] = None) -> None:
321321
super().__init__(root, transforms)
322322

323323
verify_str_arg(split, "split", valid_values=("train", "test"))

torchvision/datasets/folder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def __init__(
305305
target_transform: Optional[Callable] = None,
306306
loader: Callable[[str], Any] = default_loader,
307307
is_valid_file: Optional[Callable[[str], bool]] = None,
308-
):
308+
) -> None:
309309
super().__init__(
310310
root,
311311
loader,

torchvision/datasets/kitti.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __init__(
5757
target_transform: Optional[Callable] = None,
5858
transforms: Optional[Callable] = None,
5959
download: bool = False,
60-
):
60+
) -> None:
6161
super().__init__(
6262
root,
6363
transform=transform,

torchvision/datasets/lfw.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def __init__(
3838
transform: Optional[Callable] = None,
3939
target_transform: Optional[Callable] = None,
4040
download: bool = False,
41-
):
41+
) -> None:
4242
super().__init__(os.path.join(root, self.base_folder), transform=transform, target_transform=target_transform)
4343

4444
self.image_set = verify_str_arg(image_set.lower(), "image_set", self.file_dict.keys())
@@ -119,7 +119,7 @@ def __init__(
119119
transform: Optional[Callable] = None,
120120
target_transform: Optional[Callable] = None,
121121
download: bool = False,
122-
):
122+
) -> None:
123123
super().__init__(root, split, image_set, "people", transform, target_transform, download)
124124

125125
self.class_to_idx = self._get_classes()
@@ -201,7 +201,7 @@ def __init__(
201201
transform: Optional[Callable] = None,
202202
target_transform: Optional[Callable] = None,
203203
download: bool = False,
204-
):
204+
) -> None:
205205
super().__init__(root, split, image_set, "pairs", transform, target_transform, download)
206206

207207
self.pair_names, self.data, self.targets = self._get_pairs(self.images_dir)

torchvision/datasets/oxford_iiit_pet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def __init__(
4545
transform: Optional[Callable] = None,
4646
target_transform: Optional[Callable] = None,
4747
download: bool = False,
48-
):
48+
) -> None:
4949
self._split = verify_str_arg(split, "split", ("trainval", "test"))
5050
if isinstance(target_types, str):
5151
target_types = [target_types]

torchvision/datasets/pcam.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __init__(
7373
transform: Optional[Callable] = None,
7474
target_transform: Optional[Callable] = None,
7575
download: bool = False,
76-
):
76+
) -> None:
7777
try:
7878
import h5py
7979

torchvision/datasets/voc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def __init__(
7575
transform: Optional[Callable] = None,
7676
target_transform: Optional[Callable] = None,
7777
transforms: Optional[Callable] = None,
78-
):
78+
) -> None:
7979
super().__init__(root, transforms, transform, target_transform)
8080
if year == "2007-test":
8181
if image_set == "test":

torchvision/models/_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class WeightsEnum(StrEnum):
4848
value (Weights): The data class entry with the weight information.
4949
"""
5050

51-
def __init__(self, value: Weights):
51+
def __init__(self, value: Weights) -> None:
5252
self._value_ = value
5353

5454
@classmethod

torchvision/models/detection/anchor_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def __init__(
159159
scales: Optional[List[float]] = None,
160160
steps: Optional[List[int]] = None,
161161
clip: bool = True,
162-
):
162+
) -> None:
163163
super().__init__()
164164
if steps is not None and len(aspect_ratios) != len(steps):
165165
raise ValueError("aspect_ratios and steps should have the same length")

0 commit comments

Comments
 (0)