Skip to content

Commit eef4ebe

Browse files
Merge pull request #45 from mozilla/update-comments
Updating comments; converting from dict to str for usage with Jira pkg.
2 parents 3edd573 + 212aaa9 commit eef4ebe

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/jbi/bugzilla.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
"""
66
import datetime
7+
import json
78
import logging
89
import traceback
910
from typing import Dict, List, Optional, Tuple
@@ -100,21 +101,21 @@ class BugzillaBug(BaseModel):
100101
assigned_to: Optional[str]
101102
comment: Optional[BugzillaWebhookComment]
102103

103-
def get_whiteboard_as_list(self):
104+
def get_whiteboard_as_list(self) -> List[str]:
104105
"""Convert string whiteboard into list, splitting on ']' and removing '['."""
105106
if self.whiteboard is not None:
106107
split_list = self.whiteboard.replace("[", "").split("]")
107108
return [x.strip() for x in split_list if x not in ["", " "]]
108109
return []
109110

110-
def get_whiteboard_with_brackets_as_list(self):
111+
def get_whiteboard_with_brackets_as_list(self) -> List[str]:
111112
"""Convert string whiteboard into list, splitting on ']' and removing '['; then re-adding."""
112113
wb_list = self.get_whiteboard_as_list()
113114
if wb_list is not None and len(wb_list) > 0:
114115
return [f"[{element}]" for element in wb_list]
115116
return []
116117

117-
def get_jira_labels(self):
118+
def get_jira_labels(self) -> List[str]:
118119
"""
119120
whiteboard labels are added as a convenience for users to search in jira;
120121
bugzilla is an expected label in Jira
@@ -127,7 +128,7 @@ def get_jira_labels(self):
127128

128129
return ["bugzilla"] + wb_list + wb_bracket_list
129130

130-
def get_potential_whiteboard_config_list(self):
131+
def get_potential_whiteboard_config_list(self) -> List[str]:
131132
"""Get all possible whiteboard_tag configuration values"""
132133
converted_list: List = []
133134
for whiteboard in self.get_whiteboard_as_list():
@@ -139,12 +140,12 @@ def get_potential_whiteboard_config_list(self):
139140

140141
def convert_whiteboard_to_tag(self, whiteboard): # pylint: disable=no-self-use
141142
"""Extract tag from whiteboard label"""
142-
_exists = whiteboard not in (" ", "")
143+
_exists = whiteboard not in [" ", ""]
143144
if not _exists:
144145
return ""
145146
return whiteboard.split(sep="-", maxsplit=1)[0].lower()
146147

147-
def map_as_jira_issue(self):
148+
def map_as_jira_issue(self) -> Dict:
148149
"""Extract bug info as jira issue dictionary"""
149150
type_map: dict = {"enhancement": "Task", "task": "Task", "defect": "Bug"}
150151
return {
@@ -201,7 +202,7 @@ def map_as_tuple_of_field_dict_and_comments(
201202
self,
202203
status_log_enabled: bool = True,
203204
assignee_log_enabled: bool = True,
204-
) -> Tuple[Dict, List]:
205+
) -> Tuple[Dict, List[str]]:
205206
"""Extract update dict and comment list from Webhook Event"""
206207

207208
comments: List = []
@@ -230,7 +231,8 @@ def map_as_tuple_of_field_dict_and_comments(
230231
if change.field == "reporter":
231232
update_fields[change.field] = change.added
232233

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
234236

235237

236238
class BugzillaApiResponse(BaseModel):

0 commit comments

Comments
 (0)