From c33ea8d59761799160c92e1788e25867f5e26018 Mon Sep 17 00:00:00 2001 From: Hardik Kaurani Date: Mon, 19 Oct 2026 16:42:52 +0530 Subject: [PATCH] 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 --- sorts/bogo_sort.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sorts/bogo_sort.py b/sorts/bogo_sort.py index 16eed3bc3c1f..1bbb232cf3d6 100644 --- a/sorts/bogo_sort.py +++ b/sorts/bogo_sort.py @@ -43,7 +43,7 @@ def bogo_sort[T: Comparable](collection: list[T]) -> list[T]: TypeError: '<' not supported between instances of 'str' and 'int' """ - def is_sorted[T: Comparable](collection: list[T]) -> bool: + def is_sorted(collection: list[T]) -> bool: for i in range(len(collection) - 1): if collection[i + 1] < collection[i]: return False