MrEhsanEllahi opened a new pull request, #61573:
URL: https://github.com/apache/airflow/pull/61573

   ## Description
   
   Removed misleading TODO comments that incorrectly suggested 
`itertools.batched` (Python 3.12+) could replace the custom 
[_split_list](cci:1://file:///Users/ehsan/Desktop/projects/airflow/dev/breeze/src/airflow_breeze/utils/selective_checks.py:421:0-444:5)
 function in the Airflow Breeze utilities.
   
   ## Problem
   
   Two TODO comments (lines 422 and 1202 in 
[dev/breeze/src/airflow_breeze/utils/selective_checks.py](cci:7://file:///Users/ehsan/Desktop/projects/airflow/dev/breeze/src/airflow_breeze/utils/selective_checks.py:0:0-0:0))
 suggested that Python 3.12's `itertools.batched` could replace 
[_split_list](cci:1://file:///Users/ehsan/Desktop/projects/airflow/dev/breeze/src/airflow_breeze/utils/selective_checks.py:421:0-444:5).
 However, investigation revealed these functions have fundamentally different 
semantics:
   
   - **`itertools.batched(iterable, n)`**: Creates batches of **size** n
     - Example: [batched([1,2,3,4,5,6,7,8,9,10], 
4)](cci:1://file:///Users/ehsan/.gemini/antigravity/brain/8a7d304c-5217-488a-b6c2-cc309374d61f/test_batched_investigation.py:22:0-45:17)
 → `[[1,2,3,4], [5,6,7,8], [9,10]]` (3 batches)
     
   - **[_split_list(list, 
n)](cci:1://file:///Users/ehsan/Desktop/projects/airflow/dev/breeze/src/airflow_breeze/utils/selective_checks.py:421:0-444:5)**:
 Creates exactly **n** groups, distributed as evenly as possible
     - Example: [_split_list([1,2,3,4,5,6,7,8,9,10], 
3)](cci:1://file:///Users/ehsan/Desktop/projects/airflow/dev/breeze/src/airflow_breeze/utils/selective_checks.py:421:0-444:5)
 → `[[1,2,3,4], [5,6,7], [8,9,10]]` (3 groups)
   
   Testing showed 4 out of 7 test cases fail when attempting replacement, 
including critical edge cases like empty lists and ensuring exactly n groups 
are returned.
   
   ## Solution
   
   1. **Removed misleading TODO comments** (lines 422 and 1202)
   2. **Enhanced function docstring** with:
      - Clear explanation of the function's behavior
      - Note explaining why `itertools.batched` cannot be used
      - Detailed Args/Returns documentation
      - Practical usage example
      - Edge case documentation
   
   ## Changes Made
   
   **File Modified:**
   - 
[dev/breeze/src/airflow_breeze/utils/selective_checks.py](cci:7://file:///Users/ehsan/Desktop/projects/airflow/dev/breeze/src/airflow_breeze/utils/selective_checks.py:0:0-0:0)
   
   **Lines Changed:**
   - Lines 422-440: Enhanced 
[_split_list](cci:1://file:///Users/ehsan/Desktop/projects/airflow/dev/breeze/src/airflow_breeze/utils/selective_checks.py:421:0-444:5)
 docstring and removed TODO comment
   - Line 1215: Removed duplicate TODO comment
   
   ## Testing
   
   - No logic changes, only documentation improvements
   - Existing tests in 
[dev/breeze/tests/test_selective_checks.py](cci:7://file:///Users/ehsan/Desktop/projects/airflow/dev/breeze/tests/test_selective_checks.py:0:0-0:0)
 verify function behavior remains unchanged
   - Function is tested at lines 44 and 90 of the test file
   
   ## Type of Change
   
   - [x] Documentation update
   - [x] Code quality improvement (removed misleading comments)
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes (please specify the tool below)
   
   Generated-by: Google Gemini following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
   
   ---


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to