From e24b3c496cace1dad94e47e8e95968ec3010e270 Mon Sep 17 00:00:00 2001 From: Nicolas Hug Date: Mon, 8 Jul 2024 11:10:32 +0100 Subject: [PATCH] Ignore some mypy issues (#8516) --- torchvision/datasets/_optical_flow.py | 2 +- torchvision/datasets/_stereo_matching.py | 2 +- torchvision/datasets/widerface.py | 2 +- torchvision/utils.py | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/torchvision/datasets/_optical_flow.py b/torchvision/datasets/_optical_flow.py index 40d25583942..6d8b852a5d0 100644 --- a/torchvision/datasets/_optical_flow.py +++ b/torchvision/datasets/_optical_flow.py @@ -43,7 +43,7 @@ def __init__(self, root: Union[str, Path], transforms: Optional[Callable] = None def _read_img(self, file_name: str) -> Image.Image: img = Image.open(file_name) if img.mode != "RGB": - img = img.convert("RGB") + img = img.convert("RGB") # type: ignore[assignment] return img @abstractmethod diff --git a/torchvision/datasets/_stereo_matching.py b/torchvision/datasets/_stereo_matching.py index 6a3f563a2da..1deaab7e2f3 100644 --- a/torchvision/datasets/_stereo_matching.py +++ b/torchvision/datasets/_stereo_matching.py @@ -58,7 +58,7 @@ def __init__(self, root: Union[str, Path], transforms: Optional[Callable] = None def _read_img(self, file_path: Union[str, Path]) -> Image.Image: img = Image.open(file_path) if img.mode != "RGB": - img = img.convert("RGB") + img = img.convert("RGB") # type: ignore [assignment] return img def _scan_pairs( diff --git a/torchvision/datasets/widerface.py b/torchvision/datasets/widerface.py index 90f80b7175b..71f4ce313c3 100644 --- a/torchvision/datasets/widerface.py +++ b/torchvision/datasets/widerface.py @@ -92,7 +92,7 @@ def __getitem__(self, index: int) -> Tuple[Any, Any]: """ # stay consistent with other datasets and return a PIL Image - img = Image.open(self.img_info[index]["img_path"]) + img = Image.open(self.img_info[index]["img_path"]) # type: ignore[arg-type] if self.transform is not None: img = self.transform(img) diff --git a/torchvision/utils.py b/torchvision/utils.py index 6b2d19ec3dd..33ac826e5ce 100644 --- a/torchvision/utils.py +++ b/torchvision/utils.py @@ -612,8 +612,8 @@ def _parse_colors( colors = [ImageColor.getrgb(color) if isinstance(color, str) else color for color in colors] if dtype.is_floating_point: # [0, 255] -> [0, 1] - colors = [tuple(v / 255 for v in color) for color in colors] - return colors + colors = [tuple(v / 255 for v in color) for color in colors] # type: ignore[union-attr] + return colors # type: ignore[return-value] def _log_api_usage_once(obj: Any) -> None: