Skip to content

Commit b8b0d2e

Browse files
committed
refactor: improve type hints in linear_search.py
- Add typing import for Any type - Update linear_search parameter types from list/int to list[Any]/Any - Update rec_linear_search parameter types from list/int to list[Any]/Any - Improves type safety and IDE support while maintaining functionality Fixes #14592
1 parent 791deb4 commit b8b0d2e

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

searches/linear_search.py

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

1111

12-
def linear_search(sequence: list, target: int) -> int:
12+
from typing import Any
13+
14+
15+
def linear_search(sequence: list[Any], target: Any) -> int:
1316
"""A pure Python implementation of a linear search algorithm
1417
1518
:param sequence: a collection with comparable items (sorting is not required for
@@ -33,7 +36,7 @@ def linear_search(sequence: list, target: int) -> int:
3336
return -1
3437

3538

36-
def rec_linear_search(sequence: list, low: int, high: int, target: int) -> int:
39+
def rec_linear_search(sequence: list[Any], low: int, high: int, target: Any) -> int:
3740
"""
3841
A pure Python implementation of a recursive linear search algorithm
3942

0 commit comments

Comments
 (0)