Skip to content

Commit c33ea8d

Browse files
committed
fix(sorts): remove shadowed type parameter from bogo_sort is_sorted helper
In PEP 695 syntax, T is already bound by the outer function bogo_sort[T: Comparable]. Re-declaring [T: Comparable] on the nested is_sorted helper shadows T and causes ty check to emit error[shadowed-type-variable]. Remove [T: Comparable] from is_sorted so it uses the enclosing type variable T, matching other sorting algorithms in sorts/ (e.g. circle_sort, merge_sort). Validation: - uvx ty check sorts/bogo_sort.py -> All checks passed - uvx pytest sorts/bogo_sort.py --doctest-modules -> 1 passed - uvx pytest tests/test_sorts.py -k test_bogo_sort -> 1 passed - uvx ruff check / format -> clean
1 parent 25c712f commit c33ea8d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎sorts/bogo_sort.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def bogo_sort[T: Comparable](collection: list[T]) -> list[T]:
4343
TypeError: '<' not supported between instances of 'str' and 'int'
4444
"""
4545

46-
def is_sorted[T: Comparable](collection: list[T]) -> bool:
46+
def is_sorted(collection: list[T]) -> bool:
4747
for i in range(len(collection) - 1):
4848
if collection[i + 1] < collection[i]:
4949
return False

0 commit comments

Comments
 (0)