Vaibhav-S-Gowda opened a new pull request, #28239:
URL: https://github.com/apache/flink/pull/28239

   ## What is the purpose of the change
   
   This PR adds Python generic typing support to `DataStream` and related
   interfaces as requested in FLINK-37912. Users can now write:
   
   ```python
   ds: DataStream[int] = env.from_collection([1, 2, 3])
   result: DataStream[str] = ds.map(lambda x: str(x))
   ```
   
   and use mypy to catch type errors ahead of time.
   
   ## Brief change log
   
   - `DataStream` now extends `Generic[T]`
   - `KeyedStream` now extends `DataStream[T]` with key type `KEY`
   - `map` signature: `(Callable[[T], OUT] | MapFunction[T, OUT]) -> 
DataStream[OUT]`
   - `flat_map` signature: `(Callable[[T], Iterable[OUT]] | FlatMapFunction[T, 
OUT]) -> DataStream[OUT]`
   - `filter` signature: `(Callable[[T], bool] | FilterFunction[T]) -> 
DataStream[T]`
   - `key_by` signature: `(Callable[[T], KEY] | KeySelector[T, KEY]) -> 
KeyedStream[T, KEY]`
   - `reduce` signature: `(Callable[[T, T], T] | ReduceFunction[T]) -> 
DataStream[T]`
   - `MapFunction`, `FlatMapFunction`, `FilterFunction`, `ReduceFunction` made 
Generic
   
   ## Verifying this change
   
   This is a pure typing improvement with no runtime behavior changes.
   All existing tests continue to pass.
   
   ## Does this pull request potentially affect one of the following areas?
   
   - Python API: yes
   - Runtime: no
   - Dependencies: no
   
   ## Documentation
   
   No documentation changes required. Typing is fully backward compatible —
   existing code without type annotations continues to work unchanged.


-- 
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