[
https://issues.apache.org/jira/browse/BEAM-14547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Anand Inguva updated BEAM-14547:
--------------------------------
Description:
After debugging, the issue arises here
[https://github.com/apache/beam/blob/70cee1d125db0b62b2d660fc399e5a23845eb0e3/sdks/python/apache_beam/typehints/trivial_inference.py#L328]
The method above is not able to infer outputs properly in Python 3.10 and
results in an outputting wrong output type.
{code:java}
# Python <= 3.9
from apache_beam.typehints.trivial_inference import infer_return_type_func
wrapper = lambda x: [x]
output_type = infer_return_type_func(wrapper, [int])
# output_type would be List[int]
# Python == 3.10
wrapper = lambda x: [x]
output_type = infer_return_type_func(wrapper, [int])
# fails with error beam/sdks/python/apache_beam/typehints/opcodes.py", line #
322, in dict_update base = state.stack[-arg]
# IndexError: list index out of range
# this being in try except block, the except block returns Any. This is causing
typehint unittests to fail.
{code}
was:
After debugging, the issue arises here
[https://github.com/apache/beam/blob/70cee1d125db0b62b2d660fc399e5a23845eb0e3/sdks/python/apache_beam/typehints/trivial_inference.py#L328]
The method above is not able to infer outputs properly in 3.10 and results in
an error hence returns *Any* instead of valid output_type
{code:java}
# Python <= 3.9
from apache_beam.typehints.trivial_inference import infer_return_type_func
wrapper = lambda x: [x]
output_type = infer_return_type_func(wrapper, [int])
# output_type would be List[int]
# Python == 3.10
wrapper = lambda x: [x]
output_type = infer_return_type_func(wrapper, [int])
# fails with error beam/sdks/python/apache_beam/typehints/opcodes.py", line #
322, in dict_update base = state.stack[-arg]
# IndexError: list index out of range
# this being in try except block, the except block returns Any. This is causing
typehint unittests to fail.
{code}
> Support type inference for Python 3.10
> --------------------------------------
>
> Key: BEAM-14547
> URL: https://issues.apache.org/jira/browse/BEAM-14547
> Project: Beam
> Issue Type: Bug
> Components: sdk-py-core
> Reporter: Anand Inguva
> Assignee: Anand Inguva
> Priority: P2
>
> After debugging, the issue arises here
> [https://github.com/apache/beam/blob/70cee1d125db0b62b2d660fc399e5a23845eb0e3/sdks/python/apache_beam/typehints/trivial_inference.py#L328]
> The method above is not able to infer outputs properly in Python 3.10 and
> results in an outputting wrong output type.
> {code:java}
> # Python <= 3.9
> from apache_beam.typehints.trivial_inference import infer_return_type_func
> wrapper = lambda x: [x]
> output_type = infer_return_type_func(wrapper, [int])
> # output_type would be List[int]
> # Python == 3.10
> wrapper = lambda x: [x]
> output_type = infer_return_type_func(wrapper, [int])
> # fails with error beam/sdks/python/apache_beam/typehints/opcodes.py", line #
> 322, in dict_update base = state.stack[-arg]
> # IndexError: list index out of range
> # this being in try except block, the except block returns Any. This is
> causing typehint unittests to fail.
> {code}
--
This message was sent by Atlassian Jira
(v8.20.7#820007)