Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve: handle empty sequence case in linear_search
  • Loading branch information
snehapriy958 committed May 4, 2026
commit 234f50b0a975ace2fa4bc45affa3209530fa8d41
5 changes: 5 additions & 0 deletions searches/linear_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@
For manual testing run:
python3 linear_search.py
"""
def linear_search(sequence: list, target: int) -> int:

Check failure on line 10 in searches/linear_search.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (ARG001)

searches/linear_search.py:10:35: ARG001 Unused function argument: `target`
"""... existing docstring ..."""

if not sequence:
return -1


def linear_search(sequence: list, target: int) -> int:

Check failure on line 17 in searches/linear_search.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (F811)

searches/linear_search.py:17:5: F811 Redefinition of unused `linear_search` from line 10: `linear_search` redefined here searches/linear_search.py:10:5: previous definition of `linear_search` here help: Remove definition: `linear_search`
"""A pure Python implementation of a linear search algorithm

:param sequence: a collection with comparable items (No sorting required)
Expand Down
Loading