Unverified Commit e3941afc authored by Vasilis Vryniotis's avatar Vasilis Vryniotis Committed by GitHub
Browse files

Remove unnecessary `ignore` directives to fix mypy (#6713)

parent d020820e
...@@ -32,10 +32,10 @@ class _Feature(torch.Tensor): ...@@ -32,10 +32,10 @@ class _Feature(torch.Tensor):
return ( return (
torch.as_tensor( # type: ignore[return-value] torch.as_tensor( # type: ignore[return-value]
data, data,
dtype=dtype, # type: ignore[arg-type] dtype=dtype,
device=device, # type: ignore[arg-type] device=device,
) )
.as_subclass(cls) # type: ignore[arg-type] .as_subclass(cls)
.requires_grad_(requires_grad) .requires_grad_(requires_grad)
) )
...@@ -115,7 +115,7 @@ class _Feature(torch.Tensor): ...@@ -115,7 +115,7 @@ class _Feature(torch.Tensor):
# Inplace `func`'s, canonically identified with a trailing underscore in their name like `.add_(...)`, # Inplace `func`'s, canonically identified with a trailing underscore in their name like `.add_(...)`,
# will retain the input type. Thus, we need to unwrap here. # will retain the input type. Thus, we need to unwrap here.
if isinstance(output, cls): if isinstance(output, cls):
return output.as_subclass(torch.Tensor) # type: ignore[arg-type] return output.as_subclass(torch.Tensor)
return output return output
......
...@@ -71,7 +71,7 @@ class Image(_Feature): ...@@ -71,7 +71,7 @@ class Image(_Feature):
device: Optional[Union[torch.device, str, int]] = None, device: Optional[Union[torch.device, str, int]] = None,
requires_grad: bool = False, requires_grad: bool = False,
) -> Image: ) -> Image:
data = torch.as_tensor(data, dtype=dtype, device=device) # type: ignore[arg-type] data = torch.as_tensor(data, dtype=dtype, device=device)
if data.ndim < 2: if data.ndim < 2:
raise ValueError raise ValueError
elif data.ndim == 2: elif data.ndim == 2:
......
...@@ -16,7 +16,7 @@ def normalize( ...@@ -16,7 +16,7 @@ def normalize(
correct_type = isinstance(inpt, torch.Tensor) correct_type = isinstance(inpt, torch.Tensor)
else: else:
correct_type = features.is_simple_tensor(inpt) or isinstance(inpt, features.Image) correct_type = features.is_simple_tensor(inpt) or isinstance(inpt, features.Image)
inpt = inpt.as_subclass(torch.Tensor) # type: ignore[arg-type] inpt = inpt.as_subclass(torch.Tensor)
if not correct_type: if not correct_type:
raise TypeError(f"img should be Tensor Image. Got {type(inpt)}") raise TypeError(f"img should be Tensor Image. Got {type(inpt)}")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment