Skip to content

Commit

Permalink
Ignore some mypy issues (#8516)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug committed Jul 8, 2024
1 parent e2aff7e commit e24b3c4
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion torchvision/datasets/_optical_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion torchvision/datasets/_stereo_matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion torchvision/datasets/widerface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions torchvision/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit e24b3c4

Please sign in to comment.