andriisoldatenko commented on a change in pull request #20722:
URL: https://github.com/apache/airflow/pull/20722#discussion_r783372254



##########
File path: airflow/configuration.py
##########
@@ -493,6 +493,32 @@ def getimport(self, section, key, **kwargs):
                 f'Current value: "{full_qualified_path}".'
             )
 
+    def getjson(self, section, key, fallback=_UNSET, **kwargs) -> Union[dict, 
list, str, int, float, None]:
+        """
+        Return a config value parsed from a JSON string.
+
+        ``fallback`` is *not* JSON parsed but used verbatim when no config 
value is given.
+        """
+        # get always returns the fallback value as a string, so for this if
+        # someone gives us an object we want to keep that
+        default = _UNSET
+        if fallback is not _UNSET:
+            default = fallback
+            fallback = _UNSET
+
+        try:
+            data = self.get(section=section, key=key, fallback=fallback, 
**kwargs)
+        except (NoSectionError, NoOptionError):
+            return default
+
+        if len(data) == 0:

Review comment:
       @ashb any reason to not check `if data` instead ?




-- 
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]


Reply via email to