Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing to_type_hint to WindowedValueCoder #33403

Merged
merged 3 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sdks/python/apache_beam/coders/coders.py
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,9 @@ def from_type_hint(cls, typehint, registry):
# pickle coders.
return cls(registry.get_coder(typehint.inner_type))

def to_type_hint(self):
return typehints.WindowedValue[self.wrapped_value_coder.to_type_hint()]


Coder.register_structured_urn(
common_urns.coders.WINDOWED_VALUE.urn, WindowedValueCoder)
Expand Down
6 changes: 6 additions & 0 deletions sdks/python/apache_beam/coders/coders_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ def test_numpy_int(self):
_ = indata | "CombinePerKey" >> beam.CombinePerKey(sum)


class WindowedValueCoderTest(unittest.TestCase):
def test_to_type_hint(self):
coder = coders.WindowedValueCoder(coders.VarIntCoder())
self.assertEqual(coder.to_type_hint(), typehints.WindowedValue[int]) # type: ignore[misc]


if __name__ == '__main__':
logging.getLogger().setLevel(logging.INFO)
unittest.main()
Loading