This is an automated email from the ASF dual-hosted git repository.

shahar pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 09a15a40bcd Fix misleading TODO comments about itertools.batched 
(#61573)
09a15a40bcd is described below

commit 09a15a40bcdf746eaad2f17ba9f82d3a68beeb04
Author: Ahsan Ellahi <[email protected]>
AuthorDate: Sat Feb 7 17:39:10 2026 +0500

    Fix misleading TODO comments about itertools.batched (#61573)
---
 .../src/airflow_breeze/utils/selective_checks.py    | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/dev/breeze/src/airflow_breeze/utils/selective_checks.py 
b/dev/breeze/src/airflow_breeze/utils/selective_checks.py
index 9080999b3c5..477889d3448 100644
--- a/dev/breeze/src/airflow_breeze/utils/selective_checks.py
+++ b/dev/breeze/src/airflow_breeze/utils/selective_checks.py
@@ -419,9 +419,25 @@ def _matching_files(
     return matched_files
 
 
-# TODO: In Python 3.12 we will be able to use itertools.batched
 def _split_list(input_list, n) -> list[list[str]]:
-    """Splits input_list into n sub-lists."""
+    """
+    Splits input_list into exactly n sub-lists, distributing items as evenly 
as possible.
+
+    Note: This cannot be replaced with itertools.batched (Python 3.12+) as it 
creates
+    batches of a fixed SIZE, whereas this function creates a fixed NUMBER of 
groups.
+
+    Args:
+        input_list: List to split
+        n: Number of sub-lists to create (output will always have exactly n 
lists)
+
+    Returns:
+        List containing exactly n sub-lists with items distributed as evenly 
as possible.
+        Some sub-lists may be empty if n > len(input_list).
+
+    Example:
+        >>> _split_list([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 3)
+        [[1, 2, 3, 4], [5, 6, 7], [8, 9, 10]]
+    """
     it = iter(input_list)
     return [
         list(itertools.islice(it, i))
@@ -1199,7 +1215,6 @@ class SelectiveChecks:
             return None
         # We are hard-coding the number of lists as reasonable starting point 
to split the
         # list of test types - and we can modify it in the future
-        # TODO: In Python 3.12 we will be able to use itertools.batched
         if len(current_test_types) < NUMBER_OF_LOW_DEP_SLICES:
             return json.dumps(_get_test_list_as_json([current_test_types]))
         list_of_list_of_types = _split_list(current_test_types, 
NUMBER_OF_LOW_DEP_SLICES)

Reply via email to