Skip to content

Commit 539a5af

Browse files
committed
Refactor potentially uninitialized variable
1 parent 69d32b9 commit 539a5af

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tcms_api/plugin_helpers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,18 @@ def get_status_id_fallback(self, name):
135135
:type name: str
136136
:rtype: int
137137
"""
138+
lookup_condition = None
139+
138140
if name in ["PASSED", "WAIVED"]:
139141
lookup_condition = "weight__gt"
140142
elif name in ["FAILED", "ERROR"]:
141143
lookup_condition = "weight__lt"
144+
145+
if not lookup_condition:
146+
raise RuntimeError(
147+
f"`lookup_condition`is not initialized when searching for {name}. "
148+
"Please report a bug at https://github.com/kiwitcms/tcms-api/issues/new"
149+
)
142150
return self.get_statuses_by_weight({lookup_condition: 0})[0]["id"]
143151

144152
def get_status_id(self, name):

0 commit comments

Comments
 (0)