Skip to content

Commit 79d4a4b

Browse files
author
Akibuzzaman Akib
committed
searches: improve type hints in linear_search.py
- Narrowed list[int] generic type annotation on both linear_search() and rec_linear_search() for better type safety
1 parent 791deb4 commit 79d4a4b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

searches/linear_search.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"""
1010

1111

12-
def linear_search(sequence: list, target: int) -> int:
12+
def linear_search(sequence: list[int], target: int) -> int:
1313
"""A pure Python implementation of a linear search algorithm
1414
1515
:param sequence: a collection with comparable items (sorting is not required for
@@ -33,7 +33,7 @@ def linear_search(sequence: list, target: int) -> int:
3333
return -1
3434

3535

36-
def rec_linear_search(sequence: list, low: int, high: int, target: int) -> int:
36+
def rec_linear_search(sequence: list[int], low: int, high: int, target: int) -> int:
3737
"""
3838
A pure Python implementation of a recursive linear search algorithm
3939

0 commit comments

Comments
 (0)