You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2022/06/05 01:14:17 UTC

[GitHub] [beam] damccorm opened a new issue, #21671: Bug in type inference for Python 3.10

damccorm opened a new issue, #21671:
URL: https://github.com/apache/beam/issues/21671

   After debugging, the issue arises here
   
   [https://github.com/apache/beam/blob/70cee1d125db0b62b2d660fc399e5a23845eb0e3/sdks/python/apache_beam/typehints/trivial_inference.py#L328](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. 
   ```
   
   # Python <= 3.9 
   
   from apache_beam.typehints.trivial_inference import infer_return_type_func  
   
   fn
   = lambda x: False
   wrapper = lambda x, *args, **kwargs: [x] if fn(x, *args, **kwargs) else []
   output_type
   = infer_return_type_func(wrapper, [int])
   # output_type would be List[int]
   
   # Python == 3.10
   
   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
   
   # in python
   3.9
   from dis import dis
   print(dis(wrapper))
   
   '''
   1           0 LOAD_GLOBAL              0 (fn)
    
               2 LOAD_FAST                0 (x)
                 4 BUILD_LIST               1
            
       6 LOAD_FAST                1 (args)
                 8 LIST_EXTEND              1
                10
   LIST_TO_TUPLE
                12 BUILD_MAP                0
                14 LOAD_FAST               
   2 (kwargs)
                16 DICT_MERGE               1
                18 CALL_FUNCTION_EX         1
     
             20 POP_JUMP_IF_FALSE       28
                22 LOAD_FAST                0 (x)
             
     24 BUILD_LIST               1
                26 RETURN_VALUE
           >>   28 BUILD_LIST          
       0
                30 RETURN_VALUE
   '''
   
   # in python 3.10 
   
   print(dis(wrapper))
   '''
   1       
      0 LOAD_GLOBAL              0 (fn)
                 2 LOAD_FAST                0 (x)
                
   4 BUILD_LIST               1
                 6 LOAD_FAST                1 (args)
                 8 LIST_EXTEND 
               1
                10 LIST_TO_TUPLE
                12 BUILD_MAP                0
             
     14 LOAD_FAST                2 (kwargs)
                16 DICT_MERGE               1
                18
   CALL_FUNCTION_EX         1
                20 POP_JUMP_IF_FALSE       14 (to 28)
                22 LOAD_FAST 
                 0 (x)
                24 BUILD_LIST               1
                26 RETURN_VALUE
        
     >>   28 BUILD_LIST               0
                30 RETURN_VALUE
   '''
   
   
   
   ```
   
   
   Imported from Jira [BEAM-14547](https://issues.apache.org/jira/browse/BEAM-14547). Original Jira may contain additional context.
   Reported by: Anand Inguva.


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] AnandInguva commented on issue #21671: Bug in type inference for Python 3.10

Posted by GitBox <gi...@apache.org>.
AnandInguva commented on issue #21671:
URL: https://github.com/apache/beam/issues/21671#issuecomment-1155951559

   .take-issue


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] AnandInguva commented on issue #21671: Bug in type inference for Python 3.10

Posted by GitBox <gi...@apache.org>.
AnandInguva commented on issue #21671:
URL: https://github.com/apache/beam/issues/21671#issuecomment-1197263338

   Failed tests can be found at https://ci-beam.apache.org/job/beam_PreCommit_Python_Commit/24196/


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] yeandy commented on issue #21671: Bug in type inference for Python 3.10

Posted by GitBox <gi...@apache.org>.
yeandy commented on issue #21671:
URL: https://github.com/apache/beam/issues/21671#issuecomment-1198104243

   .take-issue


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] tvalentyn closed issue #21671: Bug in type inference for Python 3.10

Posted by GitBox <gi...@apache.org>.
tvalentyn closed issue #21671: Bug in type inference for Python 3.10
URL: https://github.com/apache/beam/issues/21671


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] damccorm commented on issue #21671: Bug in type inference for Python 3.10

Posted by GitBox <gi...@apache.org>.
damccorm commented on issue #21671:
URL: https://github.com/apache/beam/issues/21671#issuecomment-1146717264

   Unable to assign user @AnandInguva. If able, self-assign, otherwise tag @damccorm so that he can assign you. Because of GitHub's spam prevention system, your activity is required to enable assignment in this repo.


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] AnandInguva commented on issue #21671: Bug in type inference for Python 3.10

Posted by GitBox <gi...@apache.org>.
AnandInguva commented on issue #21671:
URL: https://github.com/apache/beam/issues/21671#issuecomment-1191886758

   @yeandy this is one of the bug related to Python 3.10 type inference. Can you assign this to yourself? 


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [beam] yeandy commented on issue #21671: Bug in type inference for Python 3.10

Posted by GitBox <gi...@apache.org>.
yeandy commented on issue #21671:
URL: https://github.com/apache/beam/issues/21671#issuecomment-1198105050

   Not sure if I can override the assignee by commenting `.take-issue`.


-- 
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.

To unsubscribe, e-mail: github-unsubscribe@beam.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org