From 11e06fdbc147b91f8e4351cc3bf2d0fc8a552470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0lker=20O=C4=9Fulcan=20Say=C4=B1n?= <47698920+iosayin@users.noreply.github.com> Date: Mon, 5 Oct 2026 18:05:48 +0300 Subject: [PATCH 1/4] refactor(heap): remove redundant TypeVar in Heap --- data_structures/heap/heap.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/data_structures/heap/heap.py b/data_structures/heap/heap.py index 7614e3d7f500..bf2c14c40dc9 100644 --- a/data_structures/heap/heap.py +++ b/data_structures/heap/heap.py @@ -2,18 +2,15 @@ from abc import abstractmethod from collections.abc import Iterable -from typing import Protocol, TypeVar +from typing import Protocol class Comparable(Protocol): @abstractmethod - def __gt__(self: T, other: T, /) -> bool: + def __gt__(self, other: object, /) -> bool: pass -T = TypeVar("T", bound=Comparable) - - class Heap[T: Comparable]: """A Max Heap Implementation From 958f1703287773ac51b8215997f36df64caf1f51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=B0lker=20O=C4=9Fulcan=20Say=C4=B1n?= <47698920+iosayin@users.noreply.github.com> Date: Mon, 5 Oct 2026 22:27:35 +0300 Subject: [PATCH 2/4] refactor(heap): revert Comparable.__gt__ signature to self: T, other: T --- data_structures/heap/heap.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/data_structures/heap/heap.py b/data_structures/heap/heap.py index bf2c14c40dc9..cc1e126ae1e8 100644 --- a/data_structures/heap/heap.py +++ b/data_structures/heap/heap.py @@ -2,12 +2,14 @@ from abc import abstractmethod from collections.abc import Iterable -from typing import Protocol +from typing import Protocol, TypeVar + +T = TypeVar("T") class Comparable(Protocol): @abstractmethod - def __gt__(self, other: object, /) -> bool: + def __gt__(self: T, other: T, /) -> bool: pass From d34405edc40a2019faa2d400d23803d946ba5c92 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 11 Oct 2026 18:09:33 -0930 Subject: [PATCH 3/4] Clean up imports in heap.py Removed unused TypeVar import from heap.py --- data_structures/heap/heap.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/data_structures/heap/heap.py b/data_structures/heap/heap.py index cc1e126ae1e8..4fef2d71331c 100644 --- a/data_structures/heap/heap.py +++ b/data_structures/heap/heap.py @@ -2,9 +2,7 @@ from abc import abstractmethod from collections.abc import Iterable -from typing import Protocol, TypeVar - -T = TypeVar("T") +from typing import Protocol class Comparable(Protocol): From 3a6248453c2ade8c11b344cb9602c9894a50b93f Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Sun, 11 Oct 2026 18:18:38 -0930 Subject: [PATCH 4/4] Update __gt__ method signature in Comparable class --- data_structures/heap/heap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_structures/heap/heap.py b/data_structures/heap/heap.py index 4fef2d71331c..bf2c14c40dc9 100644 --- a/data_structures/heap/heap.py +++ b/data_structures/heap/heap.py @@ -7,7 +7,7 @@ class Comparable(Protocol): @abstractmethod - def __gt__(self: T, other: T, /) -> bool: + def __gt__(self, other: object, /) -> bool: pass