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/2] 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/2] 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