From 37e897ad3dc0c5688dcef553baee19d61679fe2a Mon Sep 17 00:00:00 2001 From: SirHumza Date: Sun, 18 Oct 2026 15:14:08 +0200 Subject: [PATCH] ty: un-ignore unsupported-operator rule --- computer_vision/mean_threshold.py | 7 ++++++- pyproject.toml | 1 - sorts/iterative_merge_sort.py | 1 + sorts/quick_sort_3_partition.py | 1 + sorts/recursive_quick_sort.py | 1 + web_programming/get_amazon_product_data.py | 2 +- 6 files changed, 10 insertions(+), 3 deletions(-) diff --git a/computer_vision/mean_threshold.py b/computer_vision/mean_threshold.py index 47f9ebcb063b..316ef9a3aa7b 100644 --- a/computer_vision/mean_threshold.py +++ b/computer_vision/mean_threshold.py @@ -13,15 +13,20 @@ def mean_threshold(image: Image.Image) -> Image.Image: height, width = image.size mean = 0 pixels = image.load() + if pixels is None: + raise ValueError("image does not support pixel access") for i in range(width): for j in range(height): pixel = pixels[j, i] + assert isinstance(pixel, int | float) # grayscale images only mean += pixel mean //= width * height for j in range(width): for i in range(height): - pixels[i, j] = 255 if pixels[i, j] > mean else 0 + pixel = pixels[i, j] + assert isinstance(pixel, int | float) # grayscale images only + pixels[i, j] = 255 if pixel > mean else 0 return image diff --git a/pyproject.toml b/pyproject.toml index 932f64f2e00a..506f1b2f326d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -325,7 +325,6 @@ rules.not-subscriptable = "ignore" rules.parameter-already-assigned = "ignore" rules.unresolved-attribute = "ignore" rules.unresolved-import = "ignore" -rules.unsupported-operator = "ignore" [tool.pytest] ini_options.addopts = [ diff --git a/sorts/iterative_merge_sort.py b/sorts/iterative_merge_sort.py index 69fe76df3bc5..cfaa96434ec4 100644 --- a/sorts/iterative_merge_sort.py +++ b/sorts/iterative_merge_sort.py @@ -16,6 +16,7 @@ class Comparable(Protocol): def __lt__(self, other: Any, /) -> bool: ... + def __le__(self, other: Any, /) -> bool: ... def merge[T: Comparable](input_list: list[T], low: int, mid: int, high: int) -> list[T]: diff --git a/sorts/quick_sort_3_partition.py b/sorts/quick_sort_3_partition.py index 974fa95fca38..11cd765d2257 100644 --- a/sorts/quick_sort_3_partition.py +++ b/sorts/quick_sort_3_partition.py @@ -4,6 +4,7 @@ class Comparable(Protocol): def __lt__(self, other: Any, /) -> bool: ... + def __ge__(self, other: Any, /) -> bool: ... def quick_sort_3partition[T: Comparable]( diff --git a/sorts/recursive_quick_sort.py b/sorts/recursive_quick_sort.py index 00cc87c787df..bc518b8d1cf4 100644 --- a/sorts/recursive_quick_sort.py +++ b/sorts/recursive_quick_sort.py @@ -13,6 +13,7 @@ class Comparable(Protocol): def __ge__(self, other: Any, /) -> bool: ... + def __gt__(self, other: Any, /) -> bool: ... def __le__(self, other: Any, /) -> bool: ... diff --git a/web_programming/get_amazon_product_data.py b/web_programming/get_amazon_product_data.py index 419c477a6c0c..e40c25a458c0 100644 --- a/web_programming/get_amazon_product_data.py +++ b/web_programming/get_amazon_product_data.py @@ -57,7 +57,7 @@ def get_amazon_product_data(product: str = "laptop") -> DataFrame: ): try: product_title = item.h2.text - product_link = "https://www.amazon.in/" + item.h2.a["href"] + product_link = f"https://www.amazon.in/{item.h2.a['href']}" product_price = item.find("span", attrs={"class": "a-offscreen"}).text try: product_rating = item.find("span", attrs={"class": "a-icon-alt"}).text