BasPH commented on a change in pull request #5990: [AIRFLOW-5390] Remove provide context URL: https://github.com/apache/airflow/pull/5990#discussion_r320182021
########## File path: airflow/operators/python_operator.py ########## @@ -104,10 +97,21 @@ def execute(self, context): for k, v in airflow_context_vars.items()])) os.environ.update(airflow_context_vars) - if self.provide_context: - context.update(self.op_kwargs) - context['templates_dict'] = self.templates_dict + context.update(self.op_kwargs) + context['templates_dict'] = self.templates_dict + + if {parameter for name, parameter + in signature(self.python_callable).parameters.items() + if str(parameter).startswith("**")}: + # If there is a **kwargs, **context or **_ then just pass everything. self.op_kwargs = context + else: + # If there is only for example, an execution_date, then pass only these in :-) + self.op_kwargs = { + name: context[name] for name, parameter + in signature(self.python_callable).parameters.items() + if name in context # If it isn't available on the context, then ignore Review comment: Same here: `name: context[name] for name in signature(self.python_callable).parameters.keys() if name in context` ---------------------------------------------------------------- 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: us...@infra.apache.org With regards, Apache Git Services