Skip to content

Commit fdaa057

Browse files
committed
Add test
1 parent eaab653 commit fdaa057

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

sdks/python/apache_beam/typehints/typehints_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,6 +1599,16 @@ def expand(self, pcoll: typing.Any) -> typehints.Any:
15991599
self.assertEqual(th.input_types, ((typehints.Any, ), {}))
16001600
self.assertEqual(th.input_types, ((typehints.Any, ), {}))
16011601

1602+
def test_pipe_operator_as_union(self):
1603+
# union types can be written using pipe operator from Python 3.10.
1604+
# https://peps.python.org/pep-0604/
1605+
if sys.version_info.major == 3 and sys.version_info.minor >= 10:
1606+
type_a = int | float # pylint: disable=unsupported-binary-operation
1607+
type_b = typing.Union[int, float]
1608+
self.assertEqual(
1609+
native_type_compatibility.convert_to_beam_type(type_a),
1610+
native_type_compatibility.convert_to_beam_type(type_b))
1611+
16021612

16031613
if __name__ == '__main__':
16041614
unittest.main()

0 commit comments

Comments
 (0)