Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

Add yesqa in the pre-commit (#1246)

Edgar Ribaa0b10683ff6d
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 324e21c71..790683d67 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -62,3 +62,9 @@ repos:
hooks:
- id: docformatter
args: [--in-place, --wrap-summaries=115, --wrap-descriptions=120]
+
+ - repo: https://github.com/asottile/yesqa
+ rev: v1.2.3
+ hooks:
+ - id: yesqa
+ name: Unused noqa
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 6316cca46..3ca083c22 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -80,7 +80,7 @@ version = ''
if 'READTHEDOCS' not in os.environ:
# if developing locally, use pyro.__version__ as version
- from kornia import __version__ # noqaE402
+ from kornia import __version__
version = __version__
diff --git a/kornia/__init__.py b/kornia/__init__.py
index f157c84d1..b1baba653 100644
--- a/kornia/__init__.py
+++ b/kornia/__init__.py
@@ -6,7 +6,7 @@ if sys.version_info < (3, 6, 0):
raise RuntimeError("Kornia requires Python 3.6.0 or later")
try:
- from .version import __version__ # noqa: F401
+ from .version import __version__
except ImportError:
pass
diff --git a/kornia/feature/affine_shape.py b/kornia/feature/affine_shape.py
index 0a622e1e1..494d362ba 100644
--- a/kornia/feature/affine_shape.py
+++ b/kornia/feature/affine_shape.py
@@ -90,7 +90,7 @@ class LAFAffineShapeEstimator(nn.Module):
Args:
patch_size: the input image patch size.
affine_shape_detector: Patch affine shape estimator, :class:`~kornia.feature.PatchAffineShapeEstimator`.
- """ # noqa pylint: disable
+ """ # pylint: disable
def __init__(self, patch_size: int = 32, affine_shape_detector: Optional[nn.Module] = None) -> None:
super().__init__()
diff --git a/kornia/feature/hardnet.py b/kornia/feature/hardnet.py
index 40ed38d73..8ca4fa9f2 100644
--- a/kornia/feature/hardnet.py
+++ b/kornia/feature/hardnet.py
@@ -9,7 +9,7 @@ urls["hardnet++"] = "https://github.com/DagnyT/hardnet/raw/master/pretrained/pre
urls[
"liberty_aug"
] = "https://github.com/DagnyT/hardnet/raw/master/pretrained/train_liberty_with_aug/checkpoint_liberty_with_aug.pth" # noqa pylint: disable
-urls["hardnet8v2"] = "http://cmp.felk.cvut.cz/~mishkdmy/hardnet8v2.pt" # noqa pylint: disable
+urls["hardnet8v2"] = "http://cmp.felk.cvut.cz/~mishkdmy/hardnet8v2.pt" # pylint: disable
class HardNet(nn.Module):
diff --git a/kornia/feature/orientation.py b/kornia/feature/orientation.py
index c27400ec1..35de45487 100644
--- a/kornia/feature/orientation.py
+++ b/kornia/feature/orientation.py
@@ -203,7 +203,7 @@ class LAFOrienter(nn.Module):
num_angular_bins:
angle_detector: Patch orientation estimator, e.g. :class:`~kornia.feature.PatchDominantGradientOrientation`
or OriNet.
- """ # noqa pylint: disable
+ """ # pylint: disable
def __init__(self, patch_size: int = 32, num_angular_bins: int = 36, angle_detector: Optional[nn.Module] = None):
super().__init__()
diff --git a/kornia/feature/siftdesc.py b/kornia/feature/siftdesc.py
index 5cc9347b0..ca63f9f08 100644
--- a/kornia/feature/siftdesc.py
+++ b/kornia/feature/siftdesc.py
@@ -19,7 +19,7 @@ def get_sift_pooling_kernel(ksize: int = 25) -> torch.Tensor:
the pooling kernel with shape :math:`(ksize, ksize)`.
"""
ks_2: float = float(ksize) / 2.0
- xc2: torch.Tensor = ks_2 - (torch.arange(ksize).float() + 0.5 - ks_2).abs() # type: ignore # noqa
+ xc2: torch.Tensor = ks_2 - (torch.arange(ksize).float() + 0.5 - ks_2).abs() # type: ignore
kernel: torch.Tensor = torch.ger(xc2, xc2) / (ks_2 ** 2)
return kernel
@@ -123,7 +123,7 @@ class SIFTDescriptor(nn.Module):
padding=(self.pad, self.pad),
bias=False,
)
- self.pk.weight.data.copy_(nw.reshape(1, 1, nw.size(0), nw.size(1))) # type: ignore # noqa
+ self.pk.weight.data.copy_(nw.reshape(1, 1, nw.size(0), nw.size(1))) # type: ignore
return
def get_pooling_kernel(self) -> torch.Tensor:
@@ -164,7 +164,7 @@ class SIFTDescriptor(nn.Module):
ang_bins = []
for i in range(0, self.num_ang_bins):
- out = self.pk((bo0_big == i).to(input.dtype) * wo0_big + (bo1_big == i).to(input.dtype) * wo1_big) # noqa
+ out = self.pk((bo0_big == i).to(input.dtype) * wo0_big + (bo1_big == i).to(input.dtype) * wo1_big)
ang_bins.append(out)
ang_bins = torch.cat(ang_bins, dim=1)
ang_bins = ang_bins.view(B, -1)
diff --git a/kornia/feature/tfeat.py b/kornia/feature/tfeat.py
index 0288f65f5..8265a69f8 100644
--- a/kornia/feature/tfeat.py
+++ b/kornia/feature/tfeat.py
@@ -6,13 +6,13 @@ import torch.nn as nn
urls: Dict[str, str] = {}
urls[
"liberty"
-] = "https://github.com/vbalnt/tfeat/raw/master/pretrained-models/tfeat-liberty.params" # noqa pylint: disable
+] = "https://github.com/vbalnt/tfeat/raw/master/pretrained-models/tfeat-liberty.params" # pylint: disable
urls[
"notredame"
-] = "https://github.com/vbalnt/tfeat/raw/master/pretrained-models/tfeat-notredame.params" # noqa pylint: disable
+] = "https://github.com/vbalnt/tfeat/raw/master/pretrained-models/tfeat-notredame.params" # pylint: disable
urls[
"yosemite"
-] = "https://github.com/vbalnt/tfeat/raw/master/pretrained-models/tfeat-yosemite.params" # noqa pylint: disable
+] = "https://github.com/vbalnt/tfeat/raw/master/pretrained-models/tfeat-yosemite.params" # pylint: disable
class TFeat(nn.Module):
diff --git a/kornia/geometry/camera/pinhole.py b/kornia/geometry/camera/pinhole.py
index a8de610ee..f93f3954c 100644
--- a/kornia/geometry/camera/pinhole.py
+++ b/kornia/geometry/camera/pinhole.py
@@ -505,7 +505,7 @@ def get_optical_pose_base(pinholes: torch.Tensor) -> torch.Tensor:
# https://github.com/whh14/torchgeometry/blob/master/torchgeometry/conversions.py#L240
# But it relies on angle_axis_to_rotation_matrix
# And since then, it was changed from returning Nx4x4 matrix to Nx3x3
- # return rtvec_to_pose(optical_pose_parent) # noqa: F821 type: ignore
+ # return rtvec_to_pose(optical_pose_parent) type: ignore
def homography_i_H_ref(pinhole_i: torch.Tensor, pinhole_ref: torch.Tensor) -> torch.Tensor:
diff --git a/kornia/geometry/conversions.py b/kornia/geometry/conversions.py
index c986eeac3..d1c029b1b 100644
--- a/kornia/geometry/conversions.py
+++ b/kornia/geometry/conversions.py
@@ -288,7 +288,7 @@ def angle_axis_to_rotation_matrix(angle_axis: torch.Tensor) -> torch.Tensor:
eps = 1e-6
mask = (theta2 > eps).view(-1, 1, 1).to(theta2.device)
mask_pos = (mask).type_as(theta2)
- mask_neg = (~mask).type_as(theta2) # noqa
+ mask_neg = (~mask).type_as(theta2)
# create output pose matrix
batch_size = angle_axis.shape[0]
diff --git a/kornia/geometry/transform/imgwarp.py b/kornia/geometry/transform/imgwarp.py
index b99a1fd2e..a5b274c8c 100644
--- a/kornia/geometry/transform/imgwarp.py
+++ b/kornia/geometry/transform/imgwarp.py
@@ -626,10 +626,10 @@ def get_shear_matrix2d(center: torch.Tensor, sx: Optional[torch.Tensor] = None,
[
ones,
-sx_tan,
- sx_tan * y, # type: ignore # noqa: E241
+ sx_tan * y, # type: ignore
-sy_tan,
ones + sx_tan * sy_tan,
- sy_tan * (sx_tan * y + x), # noqa: E241
+ sy_tan * (sx_tan * y + x),
],
dim=-1,
).view(-1, 2, 3)
diff --git a/kornia/utils/metrics/confusion_matrix.py b/kornia/utils/metrics/confusion_matrix.py
index d702373b0..8bc6ef2e2 100644
--- a/kornia/utils/metrics/confusion_matrix.py
+++ b/kornia/utils/metrics/confusion_matrix.py
@@ -3,7 +3,7 @@ from typing import Optional
import torch
# Inspired by:
-# https://github.com/pytorch/tnt/blob/master/torchnet/meter/confusionmeter.py#L68-L73 # noqa
+# https://github.com/pytorch/tnt/blob/master/torchnet/meter/confusionmeter.py#L68-L73
def confusion_matrix(
diff --git a/test/augmentation/test_augmentation.py b/test/augmentation/test_augmentation.py
index ccb6a812e..2ff86bfc6 100644
--- a/test/augmentation/test_augmentation.py
+++ b/test/augmentation/test_augmentation.py
@@ -571,12 +571,12 @@ class TestRandomHorizontalFlipAlternative(CommonTests):
[[[[0.3, 0.2, 0.1], [0.6, 0.5, 0.4], [0.9, 0.8, 0.7]]]], device=self.device, dtype=self.dtype
).repeat(
(2, 1, 1, 1)
- ) # noqa: E501
+ )
expected_transformation = torch.tensor(
[[[-1.0, 0.0, 2.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]], device=self.device, dtype=self.dtype
).repeat(
(2, 1, 1)
- ) # noqa: E501
+ )
parameters = {}
self._test_random_p_1_return_transform_implementation(
input_tensor=input_tensor,
@@ -644,12 +644,12 @@ class TestRandomVerticalFlipAlternative(CommonTests):
[[[[0.7, 0.8, 0.9], [0.4, 0.5, 0.6], [0.1, 0.2, 0.3]]]], device=self.device, dtype=self.dtype
).repeat(
(2, 1, 1, 1)
- ) # noqa: E501
+ )
expected_transformation = torch.tensor(
[[[1.0, 0.0, 0.0], [0.0, -1.0, 2.0], [0.0, 0.0, 1.0]]], device=self.device, dtype=self.dtype
).repeat(
(2, 1, 1)
- ) # noqa: E501
+ )
parameters = {}
self._test_random_p_1_return_transform_implementation(
input_tensor=input_tensor,
diff --git a/test/feature/test_mkd.py b/test/feature/test_mkd.py
index 1c8f0cc50..8d11b1109 100644
--- a/test/feature/test_mkd.py
+++ b/test/feature/test_mkd.py
@@ -133,10 +133,10 @@ class TestVonMisesKernel:
patches = torch.rand(B, C, H, W, device=device, dtype=dtype)
model = (
VonMisesKernel(patch_size=13, coeffs=[0.38214156, 0.48090413]).to(patches.device, patches.dtype).eval()
- ) # noqa
+ )
model_jit = torch.jit.script(
VonMisesKernel(patch_size=13, coeffs=[0.38214156, 0.48090413]).to(patches.device, patches.dtype).eval()
- ) # noqa
+ )
assert_close(model(patches), model_jit(patches))
@@ -189,7 +189,7 @@ class TestEmbedGradients:
model = EmbedGradients(patch_size=W, relative=True).to(patches.device, patches.dtype).eval()
model_jit = torch.jit.script(
EmbedGradients(patch_size=W, relative=True).to(patches.device, patches.dtype).eval()
- ) # noqa
+ )
assert_close(model(patches), model_jit(patches))
@@ -263,7 +263,7 @@ class TestExplicitSpacialEncoding:
)
model_jit = torch.jit.script(
ExplicitSpacialEncoding(kernel_type='cart', fmap_size=W, in_dims=2).to(patches.device, patches.dtype).eval()
- ) # noqa
+ )
assert_close(model(patches), model_jit(patches))
@@ -323,7 +323,7 @@ class TestWhitening:
model = Whitening(xform='lw', whitening_model=None, in_dims=in_dims).to(patches.device, patches.dtype).eval()
model_jit = torch.jit.script(
Whitening(xform='lw', whitening_model=None, in_dims=in_dims).to(patches.device, patches.dtype).eval()
- ) # noqa
+ )
assert_close(model(patches), model_jit(patches))
@@ -401,7 +401,7 @@ class TestMKDDescriptor:
model = MKDDescriptor(patch_size=ps, kernel_type=kt, whitening=wt).to(patches.device, patches.dtype).eval()
model_jit = torch.jit.script(
MKDDescriptor(patch_size=ps, kernel_type=kt, whitening=wt).to(patches.device, patches.dtype).eval()
- ) # noqa
+ )
assert_close(model(patches), model_jit(patches))
@@ -444,8 +444,8 @@ class TestSimpleKD:
patches = torch.rand(batch_size, channels, ps, ps).to(device)
model = (
SimpleKD(patch_size=ps, kernel_type='polar', whitening='lw').to(patches.device, patches.dtype).eval()
- ) # noqa
+ )
model_jit = torch.jit.script(
SimpleKD(patch_size=ps, kernel_type='polar', whitening='lw').to(patches.device, patches.dtype).eval()
- ) # noqa
+ )
assert_close(model(patches), model_jit(patches))