Skip to content

Fix tuple type support in typecheck() and flatmap inference (fixes #632)#715

Open
Zeyad-Hassan-1 wants to merge 1 commit intoapache:mainfrom
Zeyad-Hassan-1:fix/issue-632-tuple-types
Open

Fix tuple type support in typecheck() and flatmap inference (fixes #632)#715
Zeyad-Hassan-1 wants to merge 1 commit intoapache:mainfrom
Zeyad-Hassan-1:fix/issue-632-tuple-types

Conversation

@Zeyad-Hassan-1
Copy link

Fixes #632

What was broken:

  1. Tuple Type Validation: typecheck() in types.py was not handling tuple types correctly. When a user passes (str, int) as a type, get_origin() returns None, so the existing isinstance(input_type, Tuple) check never matched.

    • Fix: Added a separate branch using isinstance(input_type, tuple) with recursion to support nested types like (typing.Tuple[str, int], typing.Tuple[str, int]).
  2. Python 3.12+ Compatibility: get_type_flatmap_function() used type(sig.return_annotation) != type(Iterable), which breaks in Python 3.12+ because Iterable and Iterable[str] are represented as different internal classes.

    • Fix: Switched to using get_origin(sig.return_annotation) is not collections.abc.Iterable for more robust validation across Python versions.

Verification:

The previously skipped test_wordcount now passes end-to-end, integrated with the Java JSON server.

Note: During testing, I observed that the word count results are consistently off by +1 for each word.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

implement tuple types support

1 participant