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):
return (
torch.as_tensor( # type: ignore[return-value]
data,
dtype=dtype, # type: ignore[arg-type]
device=device, # type: ignore[arg-type]
dtype=dtype,
device=device,
)
.as_subclass(cls) # type: ignore[arg-type]
.as_subclass(cls)
.requires_grad_(requires_grad)
)
......@@ -115,7 +115,7 @@ class _Feature(torch.Tensor):
# 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.
if isinstance(output, cls):
return output.as_subclass(torch.Tensor) # type: ignore[arg-type]
return output.as_subclass(torch.Tensor)
return output
......
......@@ -71,7 +71,7 @@ class Image(_Feature):
device: Optional[Union[torch.device, str, int]] = None,
requires_grad: bool = False,
) -> 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:
raise ValueError
elif data.ndim == 2:
......
......@@ -16,7 +16,7 @@ def normalize(
correct_type = isinstance(inpt, torch.Tensor)
else:
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:
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