kristiany commented on a change in pull request #4819: [AIRFLOW-3997] Add
getter to Variable that returns None instead of throwing
URL: https://github.com/apache/airflow/pull/4819#discussion_r263248636
##########
File path: airflow/models/__init__.py
##########
@@ -4263,6 +4263,14 @@ def setdefault(cls, key, default,
deserialize_json=False):
else:
return obj
+ @classmethod
+ @provide_session
+ def try_get(cls, key, deserialize_json=False, session=None):
+ try:
+ return cls.get(key, deserialize_json=deserialize_json,
session=session)
+ except KeyError:
+ return None
Review comment:
👍 I like this. However this will change the current behaviour when
`default_var` is set to `None` explicitly, but maybe that is not something
people do? 🤷♂️
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services