fix(data): add missing Optional and return type annotations to aggreg…#64374
Open
AyushKashyapII wants to merge 2 commits into
Open
fix(data): add missing Optional and return type annotations to aggreg…#64374AyushKashyapII wants to merge 2 commits into
AyushKashyapII wants to merge 2 commits into
Conversation
…ation API Signed-off-by: Ayush KAshyap <kashyap11ayush02@gmail.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request improves type annotations across python/ray/data/aggregate.py and python/ray/data/grouped_data.py. Specifically, it adds explicit -> None return type annotations to various __init__ constructors and wraps parameters that default to None with Optional types (such as accumulate_row, accumulate_block, on, and compute). There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes incorrect and missing type annotations in the Ray Data aggregation API (
aggregate.pyandgrouped_data.py), addressing issue #64369.These are not just style additions — several parameters had provably wrong types that mypy would flag: they defaulted to
NonebutNonewas not included in the type union.Changes in
aggregate.pyAggregateFn.__init__: wrappedaccumulate_rowandaccumulate_blockwith
Optional[...]— both defaulted toNonebut were typed as bareCallable[...], which excludesNone-> Noneto__init__of all 16 public aggregate classes:AggregateFn,AggregateFnV2,Count,AsList,Sum,Min,Max,Mean,Std,AbsMax,Quantile,Unique,CountDistinct,ValueCounter,MissingValuePercentage,ZeroPercentage,ApproximateQuantile,ApproximateTopKChanges in
grouped_data.pyGroupedData.__init__: added-> NoneGroupedData._aggregate_on: correctedonparam toOptional[Union[str, List[str]]]and added missing-> Datasetreturn typeGroupedData.map_groups: correctedcomputeparam toOptional[Union[str, ComputeStrategy]]GroupedData.sum,min,max,mean,std: correctedonparam toOptional[Union[str, List[str]]]in all five methodsWhy these are real errors, not just style
Zero runtime impact
Python ignores annotations at runtime. All changed classes were
imported and instantiated locally to confirm no regressions.