Skip to content

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

Merged
mspruc merged 1 commit into
apache:mainfrom
Zeyad-Hassan-1:fix/issue-632-tuple-types
May 20, 2026
Merged

Fix tuple type support in typecheck() and flatmap inference (fixes #632)#715
mspruc merged 1 commit into
apache:mainfrom
Zeyad-Hassan-1:fix/issue-632-tuple-types

Conversation

@Zeyad-Hassan-1
Copy link
Copy Markdown
Contributor

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.

@Zeyad-Hassan-1
Copy link
Copy Markdown
Contributor Author

Hi @zkaoudi , could you please approve the CI workflows so the checks can run? I'd also appreciate any feedback on the implementation. Thank you!

@mspruc
Copy link
Copy Markdown
Contributor

mspruc commented May 19, 2026

For some reason the actions workflows are not triggering for this PR, ill try to convert to draft to see if it helps

@mspruc mspruc marked this pull request as draft May 19, 2026 12:10
@mspruc mspruc marked this pull request as ready for review May 19, 2026 12:10
@mspruc mspruc closed this May 19, 2026
@mspruc mspruc reopened this May 19, 2026
@mspruc
Copy link
Copy Markdown
Contributor

mspruc commented May 19, 2026

weird, closing and reopening helped, your workflows are running

Copy link
Copy Markdown
Contributor

@mspruc mspruc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ty for your contribution

@mspruc mspruc merged commit 796f1fa into apache:main May 20, 2026
4 checks passed
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

2 participants