You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@beam.apache.org by "Dmytro Kozhevin (Jira)" <ji...@apache.org> on 2021/05/26 23:58:00 UTC
[jira] [Updated] (BEAM-12413) Type inference works incorrectly with
tuple slices
[ https://issues.apache.org/jira/browse/BEAM-12413?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dmytro Kozhevin updated BEAM-12413:
-----------------------------------
Description:
Returning a slice of the tuple doesn't alter the type inference output. For example:
{{@beam.typehints.with_output_types(Tuple[int, str])}}
{{class Foo(beam.DoFn):}}
{{ def process(self, a):}}
{{ yield a, str(a)}}
{{pipeline = beam.Pipeline(runner=InteractiveRunner())}}
{{pcoll = pipeline | beam.Create([1]) | beam.ParDo(Foo()) | beam.Map(lambda x: x[1:])}}
{{print(pcoll.element_type)}}
This prints Tuple[int, str], while the real type is str. At worst, this should return Any.
was:
Returning a slice of the tuple doesn't alter the type inference output. For example:
{{@beam.typehints.with_output_types(Tuple[int, str])}}
{{class Foo(beam.DoFn):}}
{{ def process(self, a):}}
{{ yield a, str(a)}}
{{pipeline = beam.Pipeline(runner=InteractiveRunner())}}
{{pcoll = pipeline | beam.Create([1]) | beam.ParDo(Foo()) | beam.Map(lambda x: x[1:])}}
{{print(pcoll.element_typ}}e)
This prints Tuple[int, str], while the real type is str. At worst, this should return Any.
> Type inference works incorrectly with tuple slices
> --------------------------------------------------
>
> Key: BEAM-12413
> URL: https://issues.apache.org/jira/browse/BEAM-12413
> Project: Beam
> Issue Type: Bug
> Components: sdk-py-core
> Reporter: Dmytro Kozhevin
> Priority: P2
>
> Returning a slice of the tuple doesn't alter the type inference output. For example:
>
> {{@beam.typehints.with_output_types(Tuple[int, str])}}
> {{class Foo(beam.DoFn):}}
> {{ def process(self, a):}}
> {{ yield a, str(a)}}
> {{pipeline = beam.Pipeline(runner=InteractiveRunner())}}
> {{pcoll = pipeline | beam.Create([1]) | beam.ParDo(Foo()) | beam.Map(lambda x: x[1:])}}
> {{print(pcoll.element_type)}}
>
> This prints Tuple[int, str], while the real type is str. At worst, this should return Any.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)