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

shahar pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/v3-1-test by this push:
     new 2b2fe8b6551 [v3-1-test] Fix misleading TODO comments about 
itertools.batched (#61573) (#61593)
2b2fe8b6551 is described below

commit 2b2fe8b6551bcd99367fb471ab2a44e1a34e33a4
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sat Feb 7 15:32:41 2026 +0200

    [v3-1-test] Fix misleading TODO comments about itertools.batched (#61573) 
(#61593)
    
    (cherry picked from commit 09a15a40bcdf746eaad2f17ba9f82d3a68beeb04)
    
    Co-authored-by: Ahsan Ellahi 
<[email protected]>
---
 .../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 3f6bb5a26af..bb7f7043661 100644
--- a/dev/breeze/src/airflow_breeze/utils/selective_checks.py
+++ b/dev/breeze/src/airflow_breeze/utils/selective_checks.py
@@ -401,9 +401,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))
@@ -1083,7 +1099,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