Skip to content

Commit 3c96273

Browse files
committed
fix: address ruff I001, UP047, and W292 in jump_search
1 parent e94ff2c commit 3c96273

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

searches/jump_search.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
from __future__ import annotations
66

77
import math
8-
from typing import Any, Protocol, TypeVar
8+
from typing import Any, Protocol
99

1010
class Comparable(Protocol):
1111
def __lt__(self, other: Any, /) -> bool: ...
1212

13-
T = TypeVar("T", bound=Comparable)
14-
15-
def jump_search(arr: list[T], item: T) -> int:
13+
def jump_search[T: Comparable](arr: list[T], item: T) -> int:
1614
"""
1715
Python implementation of the jump search algorithm.
1816
Return the index if the `item` is found, otherwise return -1.
@@ -63,4 +61,5 @@ def jump_search(arr: list[T], item: T) -> int:
6361
if res == -1:
6462
print("Number not found!")
6563
else:
66-
print(f"Number {search_item} is at index {res}")
64+
print(f"Number {search_item} is at index {res}")
65+

0 commit comments

Comments
 (0)