[ 
https://issues.apache.org/jira/browse/BEAM-8489?focusedWorklogId=347065&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-347065
 ]

ASF GitHub Bot logged work on BEAM-8489:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/Nov/19 23:07
            Start Date: 20/Nov/19 23:07
    Worklog Time Spent: 10m 
      Work Description: tvalentyn commented on pull request #9890: [BEAM-8489] 
Filter: don't use callable's output type
URL: https://github.com/apache/beam/pull/9890#discussion_r348791496
 
 

 ##########
 File path: sdks/python/apache_beam/transforms/core.py
 ##########
 @@ -1544,10 +1544,16 @@ def Filter(fn, *args, **kwargs):  # pylint: 
disable=invalid-name
   # TODO: What about callable classes?
   if hasattr(fn, '__name__'):
     wrapper.__name__ = fn.__name__
+
+  # Get type hints from this instance or the callable. Do not use output type
+  # hints from the callable (which should be bool if set).
+  fn_type_hints = typehints.decorators.IOTypeHints.from_callable(fn)
+  if fn_type_hints is not None:
+    fn_type_hints.output_types = None
 
 Review comment:
   With this change, do we still need both branches in line 1559, 1563? Perhaps 
we can make the evaluation more deterministic as in:
   ```
     if (get_type_hints(wrapper).input_types
         and get_type_hints(wrapper).input_types[0]):
       output_hint = get_type_hints(wrapper).input_types[0][0]
       get_type_hints(wrapper).set_output_types(typehints.Iterable[output_hint])
   ```
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 347065)
    Time Spent: 0.5h  (was: 20m)

> Python typehints: filter callable output type hint should not be used
> ---------------------------------------------------------------------
>
>                 Key: BEAM-8489
>                 URL: https://issues.apache.org/jira/browse/BEAM-8489
>             Project: Beam
>          Issue Type: Bug
>          Components: sdk-py-core
>            Reporter: Udi Meiri
>            Assignee: Udi Meiri
>            Priority: Major
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> A filter function returns bool, while the Filter() transform outputs the same 
> element type as the input.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to