4
4
5
5
"""
6
6
import datetime
7
+ import json
7
8
import logging
8
9
import traceback
9
10
from typing import Dict , List , Optional , Tuple
@@ -100,21 +101,21 @@ class BugzillaBug(BaseModel):
100
101
assigned_to : Optional [str ]
101
102
comment : Optional [BugzillaWebhookComment ]
102
103
103
- def get_whiteboard_as_list (self ):
104
+ def get_whiteboard_as_list (self ) -> List [ str ] :
104
105
"""Convert string whiteboard into list, splitting on ']' and removing '['."""
105
106
if self .whiteboard is not None :
106
107
split_list = self .whiteboard .replace ("[" , "" ).split ("]" )
107
108
return [x .strip () for x in split_list if x not in ["" , " " ]]
108
109
return []
109
110
110
- def get_whiteboard_with_brackets_as_list (self ):
111
+ def get_whiteboard_with_brackets_as_list (self ) -> List [ str ] :
111
112
"""Convert string whiteboard into list, splitting on ']' and removing '['; then re-adding."""
112
113
wb_list = self .get_whiteboard_as_list ()
113
114
if wb_list is not None and len (wb_list ) > 0 :
114
115
return [f"[{ element } ]" for element in wb_list ]
115
116
return []
116
117
117
- def get_jira_labels (self ):
118
+ def get_jira_labels (self ) -> List [ str ] :
118
119
"""
119
120
whiteboard labels are added as a convenience for users to search in jira;
120
121
bugzilla is an expected label in Jira
@@ -127,7 +128,7 @@ def get_jira_labels(self):
127
128
128
129
return ["bugzilla" ] + wb_list + wb_bracket_list
129
130
130
- def get_potential_whiteboard_config_list (self ):
131
+ def get_potential_whiteboard_config_list (self ) -> List [ str ] :
131
132
"""Get all possible whiteboard_tag configuration values"""
132
133
converted_list : List = []
133
134
for whiteboard in self .get_whiteboard_as_list ():
@@ -139,12 +140,12 @@ def get_potential_whiteboard_config_list(self):
139
140
140
141
def convert_whiteboard_to_tag (self , whiteboard ): # pylint: disable=no-self-use
141
142
"""Extract tag from whiteboard label"""
142
- _exists = whiteboard not in ( " " , "" )
143
+ _exists = whiteboard not in [ " " , "" ]
143
144
if not _exists :
144
145
return ""
145
146
return whiteboard .split (sep = "-" , maxsplit = 1 )[0 ].lower ()
146
147
147
- def map_as_jira_issue (self ):
148
+ def map_as_jira_issue (self ) -> Dict :
148
149
"""Extract bug info as jira issue dictionary"""
149
150
type_map : dict = {"enhancement" : "Task" , "task" : "Task" , "defect" : "Bug" }
150
151
return {
@@ -201,7 +202,7 @@ def map_as_tuple_of_field_dict_and_comments(
201
202
self ,
202
203
status_log_enabled : bool = True ,
203
204
assignee_log_enabled : bool = True ,
204
- ) -> Tuple [Dict , List ]:
205
+ ) -> Tuple [Dict , List [ str ] ]:
205
206
"""Extract update dict and comment list from Webhook Event"""
206
207
207
208
comments : List = []
@@ -230,7 +231,8 @@ def map_as_tuple_of_field_dict_and_comments(
230
231
if change .field == "reporter" :
231
232
update_fields [change .field ] = change .added
232
233
233
- return update_fields , comments
234
+ comments_as_str : List [str ] = [json .dumps (comment ) for comment in comments ]
235
+ return update_fields , comments_as_str
234
236
235
237
236
238
class BugzillaApiResponse (BaseModel ):
0 commit comments