Skip to content

Commit 37e897a

Browse files
committed
ty: un-ignore unsupported-operator rule
1 parent 25c712f commit 37e897a

6 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎computer_vision/mean_threshold.py‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,20 @@ def mean_threshold(image: Image.Image) -> Image.Image:
1313
height, width = image.size
1414
mean = 0
1515
pixels = image.load()
16+
if pixels is None:
17+
raise ValueError("image does not support pixel access")
1618
for i in range(width):
1719
for j in range(height):
1820
pixel = pixels[j, i]
21+
assert isinstance(pixel, int | float) # grayscale images only
1922
mean += pixel
2023
mean //= width * height
2124

2225
for j in range(width):
2326
for i in range(height):
24-
pixels[i, j] = 255 if pixels[i, j] > mean else 0
27+
pixel = pixels[i, j]
28+
assert isinstance(pixel, int | float) # grayscale images only
29+
pixels[i, j] = 255 if pixel > mean else 0
2530
return image
2631

2732

‎pyproject.toml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ rules.not-subscriptable = "ignore"
325325
rules.parameter-already-assigned = "ignore"
326326
rules.unresolved-attribute = "ignore"
327327
rules.unresolved-import = "ignore"
328-
rules.unsupported-operator = "ignore"
329328

330329
[tool.pytest]
331330
ini_options.addopts = [

‎sorts/iterative_merge_sort.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
class Comparable(Protocol):
1818
def __lt__(self, other: Any, /) -> bool: ...
19+
def __le__(self, other: Any, /) -> bool: ...
1920

2021

2122
def merge[T: Comparable](input_list: list[T], low: int, mid: int, high: int) -> list[T]:

‎sorts/quick_sort_3_partition.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
class Comparable(Protocol):
66
def __lt__(self, other: Any, /) -> bool: ...
7+
def __ge__(self, other: Any, /) -> bool: ...
78

89

910
def quick_sort_3partition[T: Comparable](

‎sorts/recursive_quick_sort.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
class Comparable(Protocol):
1515
def __ge__(self, other: Any, /) -> bool: ...
16+
def __gt__(self, other: Any, /) -> bool: ...
1617
def __le__(self, other: Any, /) -> bool: ...
1718

1819

‎web_programming/get_amazon_product_data.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def get_amazon_product_data(product: str = "laptop") -> DataFrame:
5757
):
5858
try:
5959
product_title = item.h2.text
60-
product_link = "https://www.amazon.in/" + item.h2.a["href"]
60+
product_link = f"https://www.amazon.in/{item.h2.a['href']}"
6161
product_price = item.find("span", attrs={"class": "a-offscreen"}).text
6262
try:
6363
product_rating = item.find("span", attrs={"class": "a-icon-alt"}).text

0 commit comments

Comments
 (0)