From 9e489bb5cf138395da2ec146d6b219aa915dc48a Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sat, 30 Sep 2023 14:57:11 +0200 Subject: [PATCH] Propagate the default/required properties of a parameter upon merge. --- platypush/utils/reflection/__init__.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/platypush/utils/reflection/__init__.py b/platypush/utils/reflection/__init__.py index 09c087838..3f9c4197d 100644 --- a/platypush/utils/reflection/__init__.py +++ b/platypush/utils/reflection/__init__.py @@ -79,6 +79,16 @@ class IntegrationMetadata: if param.doc and not params[param_name].doc: params[param_name].doc = param.doc + # If the new parameter has required=False, + # then that should also be the value for the current ones + if param.required is False: + params[param_name].required = False + + # If the new parameter has a default value, and the current + # one doesn't, then the default value should be set as the new one. + if param.default is not None and params[param_name].default is None: + params[param_name].default = param.default + @classmethod def _merge_actions(cls, actions: Dict[str, Action], new_actions: Dict[str, Action]): """