From 9e1b918570b11f5d654305ae69d337f0177f92e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Fri, 27 Sep 2024 13:26:27 +0200 Subject: [PATCH 1/2] CI updates This is done by the automated script named upgrade-c2cciutils-to-1.7 --- .pre-commit-config.yaml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 914a0ec..8f3fc55 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,12 +1,3 @@ -ci: - autoupdate_schedule: quarterly - - skip: - - copyright - - poetry-check - - poetry-lock - - ripsecrets - - jsonschema-validator repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 @@ -110,3 +101,7 @@ repos: (?x)^( ci/config\.yaml )$ + - repo: https://github.com/renovatebot/pre-commit-hooks + rev: 37.428.1 + hooks: + - id: renovate-config-validator From 07d2f398dc6fc53474a1c30aebaa9fe169a296df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Fri, 27 Sep 2024 14:15:09 +0200 Subject: [PATCH 2/2] Fix mypy typing issues --- deskew/__init__.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/deskew/__init__.py b/deskew/__init__.py index 8cb3e5a..580914a 100644 --- a/deskew/__init__.py +++ b/deskew/__init__.py @@ -3,7 +3,10 @@ import warnings from typing import TYPE_CHECKING, Any, Optional +import matplotlib.axes +import matplotlib.projections.polar import numpy as np +import numpy.typing as npt from skimage.color import rgb2gray, rgba2rgb from skimage.feature import canny from skimage.transform import hough_line, hough_line_peaks @@ -11,9 +14,9 @@ if TYPE_CHECKING: from typing import TypeAlias - ImageType: TypeAlias = np.ndarray[np.uint8, Any] - ImageTypeUint64: TypeAlias = np.ndarray[np.uint8, Any] - ImageTypeFloat64: TypeAlias = np.ndarray[np.float64, Any] + ImageType: TypeAlias = npt.NDArray[np.integer[Any] | np.floating[Any]] + ImageTypeUint64: TypeAlias = npt.NDArray[np.uint8] + ImageTypeFloat64: TypeAlias = npt.NDArray[np.float64] else: ImageType = np.ndarray ImageTypeUint64 = np.ndarray @@ -252,19 +255,19 @@ def determine_skew_debug_images( image = cv2.imread(file.name) debug_images.append(("detected_lines", cv2.imread(file.name))) - _, axe = plt.subplots(1, 2, figsize=(15, 6), subplot_kw={"polar": True}) + _, (axe0, axe1) = plt.subplots(1, 2, figsize=(15, 6), subplot_kw={"polar": True}) - axe[0].set_title("Original detected angles") - axe[1].set_title("Corrected angles") + axe0.set_title("Original detected angles") + axe1.set_title("Corrected angles") def fill_polar( - axe: Any, + axe: matplotlib.projections.polar.PolarAxes, freqs: dict[np.float64, int], angles: list[float], limits: list[tuple[float, float]], half: bool = False, ) -> None: - axe.scatter(freqs.keys(), freqs.values()) + axe.scatter(list(freqs.keys()), list(freqs.values())) axe.set_theta_zero_location("N") axe.grid(True) if half: @@ -283,8 +286,8 @@ def fill_polar( if limit_max != np.pi / 2 and (not half or -np.pi / 4 < limit_max < np.pi / 4): axe.axvline(limit_max) - fill_polar(axe[0], freqs0, skew_angles0, limits2) - fill_polar(axe[1], freqs, [] if skew_angle is None else [float(skew_angle)], limits, not angle_pm_90) + fill_polar(axe0, freqs0, skew_angles0, limits2) + fill_polar(axe1, freqs, [] if skew_angle is None else [float(skew_angle)], limits, not angle_pm_90) plt.tight_layout() with tempfile.NamedTemporaryFile(suffix=".png") as file: