Skip to content
Open
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
2 changes: 1 addition & 1 deletion python/src/pywy/tests/test_word_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def config(pytestconfig):


# TODO: implement tuple types support
@pytest.mark.skip(reason="missing implementation for tuple types in operators")
# @pytest.mark.skip(reason="missing implementation for tuple types in operators")
def test_wordcount(config):
with resources.path(resources_folder, "sample_data.md") as resource_path, \
resources.path(resources_folder, "wordcount_out_python.txt") as output_path, \
Expand Down
9 changes: 7 additions & 2 deletions python/src/pywy/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.
#

import collections
import re

from inspect import signature
Expand Down Expand Up @@ -175,7 +176,7 @@ def get_type_flatmap_function(call: FlatmapFunction) -> (type, type):
)
)

if type(sig.return_annotation) != type(Iterable):
if get_origin(sig.return_annotation) is not collections.abc.Iterable:
raise PywyException(
"the return for the FlatmapFunction is not Iterable, {}".format(
str(sig.return_annotation)
Expand All @@ -196,11 +197,15 @@ def typecheck(input_type: Type[ConstrainedOperatorType]):

if isinstance(input_type, List) and args:
typecheck(args[0])
elif isinstance(input_type, Tuple):
elif get_origin(input_type) is tuple:
if all(arg in allowed_types for arg in args):
return
else:
raise TypeError(f"Unsupported Operator type: {input_type}")
elif isinstance(input_type,tuple):
for arg in input_type:
typecheck(arg)
return
else:
raise TypeError(f"Unsupported Operator type: {input_type}, {origin}, {args}")

Expand Down