Skip to content

Commit 6f3631f

Browse files
committed
refactor: core: Change report_warning argument type to list.
Change argument type of report_warning from text: str to text: List[Union[str, Tuple[Literal["footer_contrast"], str]]].
1 parent a162a9a commit 6f3631f

File tree

4 files changed

+16
-9
lines changed

4 files changed

+16
-9
lines changed

tests/core/test_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def test_copy_to_clipboard_no_exception(
377377
else:
378378
mock_success.assert_not_called()
379379
mock_warning.assert_called_once_with(
380-
f"{text_category} copied, but the clipboard text does not match"
380+
[f"{text_category} copied, but the clipboard text does not match"]
381381
)
382382

383383
def test_copy_to_clipboard_exception(

tests/ui/test_ui_tools.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2578,7 +2578,9 @@ def test_keypress_EDIT_MESSAGE(
25782578
write_box.msg_write_box.set_edit_text.assert_not_called()
25792579
if expect_footer_text[message_type]:
25802580
if expect_editing_to_succeed[message_type]:
2581-
report_warning.assert_called_once_with(expect_footer_text[message_type])
2581+
report_warning.assert_called_once_with(
2582+
[expect_footer_text[message_type]]
2583+
)
25822584
else:
25832585
report_error.assert_called_once_with(expect_footer_text[message_type])
25842586

zulipterminal/core.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,11 @@ def report_success(
455455
"""
456456
self.view.set_footer_text(text, "task:success", duration)
457457

458-
def report_warning(self, text: str, duration: int = 3) -> None:
458+
def report_warning(
459+
self,
460+
text: List[Union[str, Tuple[Literal["footer_contrast"], str]]],
461+
duration: int = 3,
462+
) -> None:
459463
"""
460464
Helper to show a warning message in footer
461465
"""
@@ -503,7 +507,7 @@ def copy_to_clipboard(self, text: str, text_category: str) -> None:
503507
self.report_success([f"{text_category} copied successfully"])
504508
else:
505509
self.report_warning(
506-
f"{text_category} copied, but the clipboard text does not match"
510+
[f"{text_category} copied, but the clipboard text does not match"]
507511
)
508512
except pyperclip.PyperclipException:
509513
body = [

zulipterminal/ui_tools/boxes.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1875,17 +1875,18 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
18751875
return key
18761876
elif self.message["type"] == "stream":
18771877
self.model.controller.report_warning(
1878-
" Only topic editing allowed."
1879-
" Time Limit for editing the message body"
1880-
" has been exceeded."
1878+
[
1879+
" Only topic editing allowed. Time Limit for editing the message body has been exceeded."
1880+
]
18811881
)
18821882
msg_body_edit_enabled = False
18831883
elif self.message["type"] == "stream":
18841884
# Allow editing topic if the message has "(no topic)" subject
18851885
if self.message["subject"] == "(no topic)":
18861886
self.model.controller.report_warning(
1887-
" Only topic editing is allowed."
1888-
" This is someone else's message but with (no topic)."
1887+
[
1888+
" Only topic editing is allowed. This is someone else's message but with (no topic)."
1889+
]
18891890
)
18901891
msg_body_edit_enabled = False
18911892
else:

0 commit comments

Comments
 (0)