yeandy commented on code in PR #23242:
URL: https://github.com/apache/beam/pull/23242#discussion_r973132246
##########
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:
```suggestion
self.assertReturnType(typehints.Union[int, float, str],fn, [int])
```
##########
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:
I see we're getting this lint error: `Global variable 'glob' undefined at
the module level (global-variable-undefined)`. Why are we defining a global
here? Would defining `glob` outside of `def fn(obj, flag):` fix that?
I also see there are the `store_global` and `delete_global` opcodes; were
you also investigating those?
--
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]