Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

[pre-commit.ci] pre-commit suggestions (#5839)

pre-commit-ci[bot]631fb6e60972
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 85042ad38..ea4f1849c 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -20,7 +20,7 @@ repos:
exclude: ^$|.devcontainer
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: v0.16.10
+ rev: v0.17.0
hooks:
- id: ruff-check
args: [--fix, --exit-non-zero-on-fix]
diff --git a/kornia/contrib/diamond_square.py b/kornia/contrib/diamond_square.py
index 79833fa44..6aea7751b 100644
--- a/kornia/contrib/diamond_square.py
+++ b/kornia/contrib/diamond_square.py
@@ -15,7 +15,7 @@
# limitations under the License.
#
-# based on: https://github.com/anguelos/tormentor/blob/e8050ac235b0c7ad3c7d931cfa47c308a305c486/diamond_square/diamond_square.py # noqa: E501
+# based on: https://github.com/anguelos/tormentor/blob/e8050ac235b0c7ad3c7d931cfa47c308a305c486/diamond_square/diamond_square.py
import math
from typing import Callable, List, Optional, Tuple, Union
diff --git a/kornia/geometry/calibration/pnp.py b/kornia/geometry/calibration/pnp.py
index 3a3acd513..03a79d8db 100644
--- a/kornia/geometry/calibration/pnp.py
+++ b/kornia/geometry/calibration/pnp.py
@@ -158,7 +158,7 @@ def solve_pnp_dlt(
# References:
# ============
# 1. https://team.inria.fr/lagadic/camera_localization/tutorial-pose-dlt-opencv.html
- # 2. https://github.com/opencv/opencv/blob/68d15fc62edad980f1ffa15ee478438335f39cc3/modules/calib3d/src/calibration.cpp # noqa: E501
+ # 2. https://github.com/opencv/opencv/blob/68d15fc62edad980f1ffa15ee478438335f39cc3/modules/calib3d/src/calibration.cpp
# 3. http://rpg.ifi.uzh.ch/docs/teaching/2020/03_camera_calibration.pdf
# 4. http://www.cs.cmu.edu/~16385/s17/Slides/11.3_Pose_Estimation.pdf
# 5. https://www.ece.mcmaster.ca/~shirani/vision/hartley_ch7.pdf
diff --git a/kornia/geometry/homography.py b/kornia/geometry/homography.py
index 7461d40a7..0ccd92683 100644
--- a/kornia/geometry/homography.py
+++ b/kornia/geometry/homography.py
@@ -326,7 +326,7 @@ def _homography_rows(p1: torch.Tensor, points2: torch.Tensor) -> torch.Tensor:
Two rows per correspondence, ``[0, -p1, y2 p1]`` and ``[p1, 0, -x2 p1]``, so that ``row . vec(H) = 0`` for
``points2 ~ H p1`` with ``H`` row-major; only the first two coordinates of ``points2`` are read.
"""
- # DIAPO 11: https://www.uio.no/studier/emner/matnat/its/nedlagte-emner/UNIK4690/v16/forelesninger/lecture_4_3-estimating-homographies-from-feature-correspondences.pdf # noqa: E501
+ # DIAPO 11: https://www.uio.no/studier/emner/matnat/its/nedlagte-emner/UNIK4690/v16/forelesninger/lecture_4_3-estimating-homographies-from-feature-correspondences.pdf
zeros = torch.zeros_like(p1)
ax = torch.cat([zeros, -p1, points2[..., 1:2] * p1], dim=-1)
ay = torch.cat([p1, zeros, -points2[..., 0:1] * p1], dim=-1)
diff --git a/kornia/models/common.py b/kornia/models/common.py
index 2e4f58027..bc79f46af 100644
--- a/kornia/models/common.py
+++ b/kornia/models/common.py
@@ -142,7 +142,7 @@ class DropPath(nn.Module):
# From https://github.com/facebookresearch/detectron2/blob/main/detectron2/layers/batch_norm.py
-# Itself from https://github.com/facebookresearch/ConvNeXt/blob/d1fa8f6fef0a165b27399986cc2bdacc92777e40/models/convnext.py#L119 # noqa: E501
+# Itself from https://github.com/facebookresearch/ConvNeXt/blob/d1fa8f6fef0a165b27399986cc2bdacc92777e40/models/convnext.py#L119
class LayerNorm2d(nn.Module):
"""Apply Layer Normalization over a 4D input tensor (NCHW)."""
diff --git a/kornia/models/sam/architecture/image_encoder.py b/kornia/models/sam/architecture/image_encoder.py
index 1378e8424..3792a16d7 100644
--- a/kornia/models/sam/architecture/image_encoder.py
+++ b/kornia/models/sam/architecture/image_encoder.py
@@ -33,7 +33,7 @@ from kornia.models.common import LayerNorm2d, window_partition, window_unpartiti
from kornia.models.sam.architecture.common import MLPBlock
-# This class and its supporting functions below lightly adapted from the ViTDet backbone available at: https://github.com/facebookresearch/detectron2/blob/main/detectron2/modeling/backbone/vit.py # noqa: E501
+# This class and its supporting functions below lightly adapted from the ViTDet backbone available at: https://github.com/facebookresearch/detectron2/blob/main/detectron2/modeling/backbone/vit.py
class ImageEncoderViT(nn.Module):
"""Implement the Vision Transformer (ViT) based image encoder for SAM.
diff --git a/kornia/models/yunet/model.py b/kornia/models/yunet/model.py
index f616c9516..7982a7dae 100644
--- a/kornia/models/yunet/model.py
+++ b/kornia/models/yunet/model.py
@@ -15,7 +15,7 @@
# limitations under the License.
#
-# based on: https://github.com/ShiqiYu/libfacedetection.train/blob/74f3aa77c63234dd954d21286e9a60703b8d0868/tasks/task1/yufacedetectnet.py # noqa: E501
+# based on: https://github.com/ShiqiYu/libfacedetection.train/blob/74f3aa77c63234dd954d21286e9a60703b8d0868/tasks/task1/yufacedetectnet.py
from typing import Dict, List, Union
import torch
diff --git a/pyproject.toml b/pyproject.toml
index 47a19aa6f..76733a69f 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -306,6 +306,25 @@ ignore = [
"D107", # TODO: Undocumented public init
]
+[tool.ruff.lint.flake8-import-conventions.aliases]
+# Pinned to ruff 0.16's defaults, so a ruff update cannot require new aliases (0.17 added `datetime as dt`).
+altair = "alt"
+holoviews = "hv"
+matplotlib = "mpl"
+"matplotlib.pyplot" = "plt"
+networkx = "nx"
+numpy = "np"
+"numpy.typing" = "npt"
+pandas = "pd"
+panel = "pn"
+"plotly.express" = "px"
+polars = "pl"
+pyarrow = "pa"
+seaborn = "sns"
+tensorflow = "tf"
+tkinter = "tk"
+"xml.etree.ElementTree" = "ET"
+
[tool.ruff.lint.pydocstyle]
convention = "google"