[FLINK-XXXXX][python] Add type hints and fix docstrings in datastream/functions.py#28216
Open
Vaibhav-S-Gowda wants to merge 1 commit into
Open
Conversation
Collaborator
davidradl
reviewed
May 21, 2026
|
|
||
| from py4j.java_gateway import JavaObject | ||
| from typing import Union, Any, Generic, TypeVar, Iterable, List, Callable, Optional | ||
| from typing import Union, Any, Generic, TypeVar, Iterable, Iterator, List, Callable, Optional |
Contributor
There was a problem hiding this comment.
- is there a migration consideration with these changes?
- I am curious whether that can be tested maybe by having tests implementing the generic types.
- in terms of the PR title - the title should be either a square bracketed JIRA number or start with [hotfix].
Author
There was a problem hiding this comment.
Hi @davidradl, thanks for the feedback!
- These changes are backward compatible since Python generics aren't enforced at runtime, so existing subclasses won't be affected.
- I'll add tests that implement the generic types as you suggested.
- Will also create a JIRA ticket and fix the PR title.
Updates coming soon!
Author
There was a problem hiding this comment.
I've requested a JIRA account and will update the ticket number once it's approved.
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.
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
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:
Documentation
Was generative AI tooling used to co-author this PR?