From 4553f8d9a982e7e0f3e75b01fdfc33c1f3358f30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BD=B3=E8=88=AA?= Date: Fri, 26 Jun 2026 17:34:29 +0800 Subject: [PATCH 1/2] Add type hints to linear search functions Add `list[int]` type annotations to parameters and return values in linear_search.py, sentinel_linear_search.py, and double_linear_search_recursion.py to match repository coding standards. --- searches/double_linear_search_recursion.py | 2 +- searches/linear_search.py | 4 ++-- searches/sentinel_linear_search.py | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/searches/double_linear_search_recursion.py b/searches/double_linear_search_recursion.py index 1c483e974ca7..983956f3e56c 100644 --- a/searches/double_linear_search_recursion.py +++ b/searches/double_linear_search_recursion.py @@ -1,4 +1,4 @@ -def search(list_data: list, key: int, left: int = 0, right: int = 0) -> int: +def search(list_data: list[int], key: int, left: int = 0, right: int = 0) -> int: """ Iterate through the array to find the index of key using recursion. :param list_data: the list to be searched diff --git a/searches/linear_search.py b/searches/linear_search.py index 8adb4a7015f0..98de2534ee96 100644 --- a/searches/linear_search.py +++ b/searches/linear_search.py @@ -9,7 +9,7 @@ """ -def linear_search(sequence: list, target: int) -> int: +def linear_search(sequence: list[int], target: int) -> int: """A pure Python implementation of a linear search algorithm :param sequence: a collection with comparable items (sorting is not required for @@ -33,7 +33,7 @@ def linear_search(sequence: list, target: int) -> int: return -1 -def rec_linear_search(sequence: list, low: int, high: int, target: int) -> int: +def rec_linear_search(sequence: list[int], low: int, high: int, target: int) -> int: """ A pure Python implementation of a recursive linear search algorithm diff --git a/searches/sentinel_linear_search.py b/searches/sentinel_linear_search.py index 69c1cf9f351a..ccdcaa631974 100644 --- a/searches/sentinel_linear_search.py +++ b/searches/sentinel_linear_search.py @@ -9,9 +9,10 @@ For manual testing run: python sentinel_linear_search.py """ +from __future__ import annotations -def sentinel_linear_search(sequence, target): +def sentinel_linear_search(sequence: list[int], target: int) -> int | None: """Pure implementation of sentinel linear search algorithm in Python :param sequence: some sequence with comparable items From 5b9e36d2798833447e046d1ec9c94022efd3fbc6 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 26 Jun 2026 09:49:18 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- searches/sentinel_linear_search.py | 1 + 1 file changed, 1 insertion(+) diff --git a/searches/sentinel_linear_search.py b/searches/sentinel_linear_search.py index ccdcaa631974..ca1119c3b4cc 100644 --- a/searches/sentinel_linear_search.py +++ b/searches/sentinel_linear_search.py @@ -9,6 +9,7 @@ For manual testing run: python sentinel_linear_search.py """ + from __future__ import annotations