From 83fc940f54e5d6531f66bff256f66765899dc055 Mon Sep 17 00:00:00 2001 From: Leo Gallucci Date: Thu, 26 Jul 2018 07:51:37 +0200 Subject: [PATCH] Fix deprecated arguments for HipChat Operator Fix models.py:2390: PendingDeprecationWarning: Invalid arguments were passed to HipChatAPISendRoomNotificationOperator. Support for passing such arguments will be dropped in Airflow 2.0. https://github.com/apache/incubator-airflow/blob/8715bc45b448c9c346/airflow/models.py#L2382 Invalid arguments were: ``` *args: () **kwargs: {'color': 'green'} ``` category=PendingDeprecationWarning --- airflow/contrib/operators/hipchat_operator.py | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/airflow/contrib/operators/hipchat_operator.py b/airflow/contrib/operators/hipchat_operator.py index 381cd72cdf722..25a77fa19b0cb 100644 --- a/airflow/contrib/operators/hipchat_operator.py +++ b/airflow/contrib/operators/hipchat_operator.py @@ -99,24 +99,21 @@ class HipChatAPISendRoomNotificationOperator(HipChatAPIOperator): :param card: HipChat-defined card object :type card: dict """ - template_fields = ('token', 'room_id', 'message') + template_fields = ('token', 'room_id', 'message', 'message_format', 'color', 'frm', 'attach_to', 'notify', 'card') ui_color = '#2980b9' @apply_defaults - def __init__(self, room_id, message, *args, **kwargs): + def __init__(self, room_id, message, message_format='html', color='yellow', frm='airflow', attach_to=None, notify=False, card=None, *args, **kwargs): super(HipChatAPISendRoomNotificationOperator, self).__init__(*args, **kwargs) self.room_id = room_id self.message = message - default_options = { - 'message_format': 'html', - 'color': 'yellow', - 'frm': 'airflow', - 'attach_to': None, - 'notify': False, - 'card': None - } - for (prop, default) in default_options.items(): - setattr(self, prop, kwargs.get(prop, default)) + self.message_format = message_format + self.color = color + self.frm = frm + self.attach_to = attach_to + self.notify = notify + self.card = card + def prepare_request(self): params = {