Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

remove type ignore (#2078)

João Gustavo A. Amorim6e8d94504cc6
diff --git a/kornia/augmentation/random_generator/_2d/affine.py b/kornia/augmentation/random_generator/_2d/affine.py
index 92fdd6268..0ae8fe685 100644
--- a/kornia/augmentation/random_generator/_2d/affine.py
+++ b/kornia/augmentation/random_generator/_2d/affine.py
@@ -79,9 +79,7 @@ class AffineGenerator(RandomGeneratorBase):
_scale = concatenate(
[
_range_bound(self.scale[:2], 'scale_x', bounds=(0, float('inf')), check='singular'),
- _range_bound(
- self.scale[2:], 'scale_y', bounds=(0, float('inf')), check='singular' # type:ignore
- ),
+ _range_bound(self.scale[-2:], 'scale_y', bounds=(0, float('inf')), check='singular'),
]
).to(device=device, dtype=dtype)
else:
diff --git a/kornia/augmentation/random_generator/_2d/crop.py b/kornia/augmentation/random_generator/_2d/crop.py
index 5ba0015a2..408e6cf99 100644
--- a/kornia/augmentation/random_generator/_2d/crop.py
+++ b/kornia/augmentation/random_generator/_2d/crop.py
@@ -227,11 +227,11 @@ class ResizedCropGenerator(CropGenerator):
if not cond_bool.all():
# Fallback to center crop
in_ratio = float(size[0]) / float(size[1])
- _min = self.ratio.min() if isinstance(self.ratio, Tensor) else min(self.ratio)
- if in_ratio < _min: # type:ignore
+ _min = float(self.ratio.min()) if isinstance(self.ratio, Tensor) else min(self.ratio)
+ if in_ratio < _min:
h_ct = tensor(size[0], device=_device, dtype=_dtype)
w_ct = torch.round(h_ct / _min)
- elif in_ratio > _min: # type:ignore
+ elif in_ratio > _min:
w_ct = tensor(size[1], device=_device, dtype=_dtype)
h_ct = torch.round(w_ct * _min)
else: # whole image
diff --git a/kornia/grad_estimator/ste.py b/kornia/grad_estimator/ste.py
index 29c50fe8f..1317420c9 100644
--- a/kornia/grad_estimator/ste.py
+++ b/kornia/grad_estimator/ste.py
@@ -1,4 +1,4 @@
-from typing import Callable, Optional, Tuple
+from typing import Any, Callable, Optional, Tuple
import torch.nn as nn
from torch import Tensor
@@ -36,8 +36,8 @@ class STEFunction(Function):
"""
@staticmethod
- def forward( # type:ignore
- ctx, input: Tensor, output: Tensor, grad_fn: Optional[Callable] = None
+ def forward( # type: ignore[override]
+ ctx: Any, input: Tensor, output: Tensor, grad_fn: Optional[Callable[..., Any]] = None
) -> Tensor:
ctx.in_shape = input.shape
ctx.out_shape = output.shape
@@ -45,7 +45,7 @@ class STEFunction(Function):
return output
@staticmethod
- def backward(ctx, grad_output: Tensor) -> Tuple[Tensor, Tensor, None]: # type:ignore
+ def backward(ctx: Any, grad_output: Tensor) -> Tuple[Tensor, Tensor, None]: # type: ignore[override]
if ctx.grad_fn is None:
return grad_output.sum_to_size(ctx.in_shape), grad_output.sum_to_size(ctx.out_shape), None
return (