cccs-seb commented on a change in pull request #14663:
URL: https://github.com/apache/airflow/pull/14663#discussion_r590796257
##########
File path: airflow/operators/python.py
##########
@@ -489,7 +489,9 @@ def __init__( # pylint: disable=too-many-arguments
self.pickling_library = dill if self.use_dill else pickle
def execute(self, context: Dict):
- serializable_context = {key: context[key] for key in
self._get_serializable_context_keys()}
+ serializable_context = {
+ key: context[key] for key in self._get_serializable_context_keys()
if context.get(key) is not None
+ }
Review comment:
With the previous code, if I passed an empty context object to test the
execute method, it would throw a KeyError when it tries to do `key:
context[key]`. Essentially, if I can't provide a context object with all the
keys from _get_serializable_context_keys, an KeyError will be thrown.
Most operator execute method tests I have seen use an empty context object
as param to test. I tried to do the same here which required the change above.
----------------------------------------------------------------
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]