Vaibhav-S-Gowda opened a new pull request, #28216:
URL: https://github.com/apache/flink/pull/28216
## What is the purpose of the change
This pull request adds explicit generic type hints (IN, OUT, KEY)
to core abstract method signatures in pyflink/datastream/functions.py
and fixes several docstring issues. These methods form the foundational
public API for PyFlink DataStream users, and the absence of type
annotations was reducing IDE autocompletion quality and preventing
effective mypy static analysis on user code extending these classes.
Additionally, MapFunction, CoMapFunction and KeySelector are made
properly Generic (like AsyncFunction and WindowFunction already are),
enabling correct TypeVar binding across the class hierarchy.
## Brief change log
- Made MapFunction properly Generic[IN, OUT]
- Made CoMapFunction properly Generic[IN, OUT]
- Made KeySelector properly Generic[IN, KEY]
- Added Iterator to typing imports
- Added return type None to Function.open and Function.close
- Added (IN) -> OUT to MapFunction.map
- Added (IN) -> OUT to CoMapFunction.map1 and map2
- Added (IN) -> Iterator[OUT] to FlatMapFunction.flat_map
- Added (IN) -> Iterator[OUT] to CoFlatMapFunction.flat_map1 and flat_map2
- Added (IN, IN) -> IN to ReduceFunction.reduce
- Added (IN) -> bool to FilterFunction.filter
- Added (IN) -> KEY to KeySelector.get_key
- Added (IN, Context) -> Iterator[OUT] to ProcessFunction.process_element
- Added (IN, Context) -> Iterator[OUT] to
KeyedProcessFunction.process_element
- Added (IN, Context) -> Iterator[OUT] to
CoProcessFunction.process_element1 and process_element2
- Fixed typo: "mthod" → "method" in FlatMapFunction.flat_map docstring
- Fixed typo: "MapFUnction" → "MapFunction" in FlatMapFunction class
docstring
- Fixed doctest continuation lines: >>> → ... inside class body examples
## Verifying this change
This change is a trivial rework / code cleanup without any test coverage.
Verified with mypy:
mypy pyflink/datastream/functions.py --ignore-missing-imports
--follow-imports=skip
Result: Success: no issues found in 1 source file
## Does this pull request potentially affect one of the following parts:
- Dependencies: no
- The public API: yes
- The serializers: no
- The runtime per-record code paths: no
- Anything that affects deployment or recovery: no
- The S3 file system connector: no
## Documentation
- Does this pull request introduce a new feature? no
- If yes, how is the feature documented? not applicable
##### Was generative AI tooling used to co-author this PR?
- [ ] Yes
--
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]