From ba916e077c47bf23de29d899c8a6e14fb6ff3d85 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 5 Mar 2026 11:39:04 +0000 Subject: [PATCH] Return list from sort_items So we can rely on this behavior even if a sort_str is not provided. Change-Id: Ic241cba9cf2954eb41bd611e5d4384e5f5ff7286 Signed-off-by: Stephen Finucane --- osc_lib/utils/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/osc_lib/utils/__init__.py b/osc_lib/utils/__init__.py index 2b8d0116..c64358bd 100644 --- a/osc_lib/utils/__init__.py +++ b/osc_lib/utils/__init__.py @@ -660,7 +660,7 @@ def sort_items( items: collections.abc.Sequence[_T], sort_str: str, sort_type: type[ty.Any] | None = None, -) -> collections.abc.Sequence[_T]: +) -> list[_T]: """Sort items based on sort keys and sort directions given by sort_str. :param items: a list or generator object of items @@ -671,7 +671,9 @@ def sort_items( :return: sorted items """ if not sort_str: - return items + # wrap in list so we return a consistent type + return list(items) + # items may be a generator object, transform it to a list items = list(items) sort_keys = sort_str.strip().split(',')