Files
Python/tests
RokeshwaranandChristian Clauss 9ec2f097fe sorts: make recursive_insertion_sort generic over Comparable items (#15340)
* sorts: make recursive_insertion_sort generic over Comparable items

Part of #15234

- switch rec_insertion_sort/insert_next to the Comparable/TypeVar-bound
  MutableSequence[T] pattern (in-place sorts bucket) per the convention
  discussed on #15234
- make rec_insertion_sort return the sorted collection and give n a
  default of len(collection), so it can be called with a single
  argument like the other sorts in the shared test battery
- add a string doctest
- register rec_insertion_sort in tests/test_sorts.py's shared SORTS
  battery and the non-comparable-items rejection test

* fix: keep rec_insertion_sort in-place with None return, per maintainer review

- Revert n to a required parameter and drop the MutableSequence[T] return
  value; rec_insertion_sort stays a pure in-place sort returning None, as
  requested in review.
- Keep the Comparable/TypeVar generalization (no PEP 695 syntax, to match
  the existing TypeVar style in the file).
- Keep the non-int (string) doctest.
- tests/test_sorts.py: rec_insertion_sort no longer fits the shared SORTS
  battery (which asserts on a returned value), so it's removed from that
  tuple and given its own parametrized in-place test, plus its own
  non-comparable-items rejection test.

* test: adjust test_sorts.py for rec_insertion_sort's None-returning in-place contract

rec_insertion_sort no longer fits the shared SORTS battery (which asserts
on a returned value), so it's removed from that tuple and given its own
parametrized in-place test (checked against sorted()) plus its own
non-comparable-items rejection test.

* Apply batched suggestions from code review

Co-authored-by: Christian Clauss <cclauss@me.com>

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
2026-09-21 14:03:36 +02:00
..
2026-09-04 19:52:14 +02:00