Skip to content

Commit 807dff8

Browse files
committed
Add type hints to tim_sort.py, relates to #14457
1 parent 841e947 commit 807dff8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sorts/tim_sort.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
def binary_search(lst, item, start, end):
1+
def binary_search(lst: list[int | float], item: int | float, start: int, end: int) -> int:
22
if start == end:
33
return start if lst[start] > item else start + 1
44
if start > end:
@@ -13,7 +13,7 @@ def binary_search(lst, item, start, end):
1313
return mid
1414

1515

16-
def insertion_sort(lst):
16+
def insertion_sort(lst: list[int | float]) -> list[int | float]:
1717
length = len(lst)
1818

1919
for index in range(1, length):
@@ -24,7 +24,7 @@ def insertion_sort(lst):
2424
return lst
2525

2626

27-
def merge(left, right):
27+
def merge(left: list[int | float], right: list[int | float]) -> list[int | float]:
2828
if not left:
2929
return right
3030

@@ -37,7 +37,7 @@ def merge(left, right):
3737
return [right[0], *merge(left, right[1:])]
3838

3939

40-
def tim_sort(lst):
40+
def tim_sort(lst: list[int | float]) -> list[int | float]:
4141
"""
4242
>>> tim_sort("Python")
4343
['P', 'h', 'n', 'o', 't', 'y']

0 commit comments

Comments
 (0)