caneff commented on code in PR #28454:
URL: https://github.com/apache/beam/pull/28454#discussion_r1327592711
##########
sdks/python/apache_beam/dataframe/frame_base_test.py:
##########
@@ -129,6 +132,45 @@ def func_removed_args(self, a, c, **kwargs):
proxy.func_removed_args()
self.assertEqual(proxy.func_removed_args(12, d=100), {'a': 12, 'd': 100})
+ def test_args_to_kwargs_populates_default_handles_kw_only(self):
+ class Base(object):
+ def func(self, a=1, b=2, c=3, *, kw_only=4):
+ pass
+
+ class ProxyUsesKwOnly(object):
+ @frame_base.args_to_kwargs(Base)
+ @frame_base.populate_defaults(Base)
+ def func(self, a, kw_only, **kwargs):
+ return dict(kwargs, a=a, kw_only=kw_only)
+
+ proxy = ProxyUsesKwOnly()
+
+ # pylint: disable=too-many-function-args,no-value-for-parameter
+ self.assertEqual(proxy.func(), {'a': 1, 'kw_only': 4})
+ self.assertEqual(proxy.func(100), {'a': 100, 'kw_only': 4})
+ self.assertEqual(
+ proxy.func(2, 4, 6, kw_only=8), {
+ 'a': 2, 'b': 4, 'c': 6, 'kw_only': 8
+ })
+ with self.assertRaises(TypeError):
+ proxy.func(2, 4, 6, 8) # got too many positioned arguments
+
+ class ProxyDoesntUseKwOnly(object):
+ @frame_base.args_to_kwargs(Base)
+ @frame_base.populate_defaults(Base)
+ def func(self, a, **kwargs):
+ return dict(kwargs, a=a)
+
+ proxy = ProxyDoesntUseKwOnly()
+
+ # pylint: disable=too-many-function-args,no-value-for-parameter
+ self.assertEqual(proxy.func(), {'a': 1})
Review Comment:
Because this is only populating defaults for the proxy function. `b`, `c`
and `kw_only` are not arguments in the proxy function
--
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]