[
https://issues.apache.org/jira/browse/BEAM-6877?focusedWorklogId=284623&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-284623
]
ASF GitHub Bot logged work on BEAM-6877:
----------------------------------------
Author: ASF GitHub Bot
Created on: 29/Jul/19 23:58
Start Date: 29/Jul/19 23:58
Worklog Time Spent: 10m
Work Description: udim commented on pull request #8893: [BEAM-6877]
trivial_inference: make remaining tests pass
URL: https://github.com/apache/beam/pull/8893#discussion_r308484694
##########
File path: sdks/python/apache_beam/typehints/trivial_inference_test.py
##########
@@ -235,6 +235,60 @@ def m(self, x):
self.assertReturnType(typehints.Any, lambda: A.m(A(), 3.0), depth=0)
self.assertReturnType(float, lambda: A.m(A(), 3.0), depth=1)
+ # pylint: disable=eval-used
+ # TODO(udim): Remove eval() call once Python 2 support is removed from Beam.
+ @unittest.skipIf(sys.version_info < (3,), 'Python 3 only')
+ def testBuildListUnpack(self):
+ # Lambda uses BUILD_LIST_UNPACK opcode in Python 3.
+ # Uses eval() to hide Python 3 syntax from Python 2.
+ eval('''self.assertReturnType(typehints.List[int],
+ lambda _list: [*_list, *_list, *_list],
+ [typehints.List[int]])''')
+
+ # TODO(udim): Remove eval() call once Python 2 support is removed from Beam.
+ @unittest.skipIf(sys.version_info < (3,), 'Python 3 only')
+ def testBuildTupleUnpack(self):
+ # Lambda uses BUILD_TUPLE_UNPACK opcode in Python 3.
+ # Uses eval() to hide Python 3 syntax from Python 2.
+ eval('''self.assertReturnType(
+ typehints.Tuple[int, str, str],
+ lambda _list1, _list2: (*_list1, *_list2, *_list2),
+ [typehints.List[int], typehints.List[str]])''')
+ # pylint: enable=eval-used
+
+ def testBuildTupleUnpackWithCall(self):
+ # Lambda uses BUILD_TUPLE_UNPACK_WITH_CALL opcode in Python 3.6, 3.7.
+ def fn(x1, x2, *unused_args):
+ return x1, x2
+
+ self.assertReturnType(typehints.Tuple[str, float],
+ lambda x1, x2, _list: fn(x1, x2, *_list),
+ [str, float, typehints.List[int]])
+ # No *args
+ self.assertReturnType(typehints.Tuple[str, typehints.List[int]],
+ lambda x1, x2, _list: fn(x1, x2, *_list),
+ [str, typehints.List[int]])
+
+ @unittest.skipIf(sys.version_info < (3, 6), 'CALL_FUNCTION_EX is new in 3.6')
+ def testCallFunctionEx(self):
+ # Test when fn arguments are built using BUiLD_LIST.
Review comment:
I'll leave this for my next PR as I don't want to reset the tests.
----------------------------------------------------------------
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: 284623)
Time Spent: 13.5h (was: 13h 20m)
> TypeHints Py3 Error: Type inference tests fail on Python 3.6 due to bytecode
> changes
> ------------------------------------------------------------------------------------
>
> Key: BEAM-6877
> URL: https://issues.apache.org/jira/browse/BEAM-6877
> Project: Beam
> Issue Type: Sub-task
> Components: sdk-py-core
> Reporter: Robbe
> Assignee: Udi Meiri
> Priority: Major
> Time Spent: 13.5h
> Remaining Estimate: 0h
>
> Type inference doesn't work on Python 3.6 due to [bytecode to wordcode
> changes|https://docs.python.org/3/whatsnew/3.6.html#cpython-bytecode-changes].
> Type inference always returns Any on Python 3.6, so this is not critical.
> Affected tests are:
> *transforms.ptransform_test*:
> - test_combine_properly_pipeline_type_checks_using_decorator
> - test_mean_globally_pipeline_checking_satisfied
> - test_mean_globally_runtime_checking_satisfied
> - test_count_globally_pipeline_type_checking_satisfied
> - test_count_globally_runtime_type_checking_satisfied
> - test_pardo_type_inference
> - test_pipeline_inference
> - test_inferred_bad_kv_type
> *typehints.trivial_inference_test*:
> - all tests in TrivialInferenceTest
> *io.gcp.pubsub_test.TestReadFromPubSubOverride*:
> * test_expand_with_other_options
> * test_expand_with_subscription
> * test_expand_with_topic
--
This message was sent by Atlassian JIRA
(v7.6.14#76016)