From 763179e73d365dd6aa05916dd70235b20ca3b1b9 Mon Sep 17 00:00:00 2001 From: peeyushtiwary27 Date: Fri, 25 Sep 2026 01:28:31 +0530 Subject: [PATCH 1/2] fix typing issues for invalid-assignment --- computer_vision/mean_threshold.py | 2 +- other/dancing_links.py | 6 ++++++ sorts/benchmark_sorts.py | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/computer_vision/mean_threshold.py b/computer_vision/mean_threshold.py index 47f9ebcb063b..b13d4445daf5 100644 --- a/computer_vision/mean_threshold.py +++ b/computer_vision/mean_threshold.py @@ -21,7 +21,7 @@ def mean_threshold(image: Image.Image) -> Image.Image: for j in range(width): for i in range(height): - pixels[i, j] = 255 if pixels[i, j] > mean else 0 + image.putpixel((i, j), 255 if pixels[i, j] > mean else 0) return image diff --git a/other/dancing_links.py b/other/dancing_links.py index e611e891cc7f..57f98603af44 100644 --- a/other/dancing_links.py +++ b/other/dancing_links.py @@ -21,6 +21,12 @@ class DLXNode: """Represents a node in the Dancing Links structure.""" + left: "DLXNode" + right: "DLXNode" + up: "DLXNode" + down: "DLXNode" + column: "ColumnNode | None" + def __init__(self) -> None: self.left = self.right = self.up = self.down = self self.column = None diff --git a/sorts/benchmark_sorts.py b/sorts/benchmark_sorts.py index 72b6b487e1a9..094374a9773b 100644 --- a/sorts/benchmark_sorts.py +++ b/sorts/benchmark_sorts.py @@ -25,6 +25,9 @@ from timeit import timeit from typing import Protocol +class SortFunction(Protocol): + def __call__[T](self, collection: list[T], /) -> Sequence[T]: ... + from sorts.bubble_sort import bubble_sort_iterative from sorts.cocktail_shaker_sort import cocktail_shaker_sort from sorts.comb_sort import comb_sort @@ -38,7 +41,7 @@ from sorts.tim_sort import tim_sort # name -> callable. Every callable accepts a list and returns the sorted list. -SORTS: dict[str, Callable[[list[int]], Sequence[int]]] = { +SORTS: dict[str, SortFunction] = { "bubble_sort": bubble_sort_iterative, "cocktail_shaker_sort": cocktail_shaker_sort, "comb_sort": comb_sort, From 9555b9382bc55808be88978fa499dac2700ef848 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 24 Sep 2026 20:05:43 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- sorts/benchmark_sorts.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sorts/benchmark_sorts.py b/sorts/benchmark_sorts.py index 094374a9773b..2cb3cbdfc1b6 100644 --- a/sorts/benchmark_sorts.py +++ b/sorts/benchmark_sorts.py @@ -25,9 +25,11 @@ from timeit import timeit from typing import Protocol + class SortFunction(Protocol): def __call__[T](self, collection: list[T], /) -> Sequence[T]: ... + from sorts.bubble_sort import bubble_sort_iterative from sorts.cocktail_shaker_sort import cocktail_shaker_sort from sorts.comb_sort import comb_sort