robertwb commented on code in PR #23242:
URL: https://github.com/apache/beam/pull/23242#discussion_r984103609
##########
sdks/python/apache_beam/typehints/trivial_inference_test.py:
##########
@@ -258,6 +258,26 @@ def testGetAttr(self):
typehints.Tuple[str, typehints.Any],
lambda: (typehints.__doc__, typehints.fake))
+ def testSetAttr(self):
+ def fn(obj, flag):
+ global glob
+ if flag == 1:
+ obj.attr = 1
+ res = 1
+ elif flag == 2:
+ obj.attr = 2
+ res = 1.5
+ elif flag == 3:
+ glob = 3
+ res = "str"
+ elif flag == 4:
+ del glob
+ res = "another str"
+ return res
+ self.assertReturnType(
+ typehints.Union[int, float, str],
+ fn, [int])
Review Comment:
Done.
##########
sdks/python/apache_beam/typehints/trivial_inference_test.py:
##########
@@ -258,6 +258,26 @@ def testGetAttr(self):
typehints.Tuple[str, typehints.Any],
lambda: (typehints.__doc__, typehints.fake))
+ def testSetAttr(self):
+ def fn(obj, flag):
+ global glob
Review Comment:
Yes, these were correct, but I added a test for them. I've now separated
that out into a separate test to be more clear (and disabled the hint warning
that isn't useful here).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]