Skip to content

Commit 80b1161

Browse files
committed
mypy: Clarify keypress methods can return Optional[str] per urwid docs.
1 parent 3998e58 commit 80b1161

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

zulipterminal/ui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def show_right_panel(self, *, visible: bool) -> None:
146146
self.body.focus_position = 2
147147

148148
# FIXME: The type of size should be urwid_Size; this needs checking
149-
def keypress(self, size: Tuple[int, int], key: str) -> str:
149+
def keypress(self, size: Tuple[int, int], key: str) -> Optional[str]:
150150
self.model.new_user_input = True
151151
if self.controller.editor_mode:
152152
return self.controller.editor.keypress((size[1],), key)

zulipterminal/ui_tools/boxes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def autocomplete_streams(self, text: str, state: int) -> Optional[str]:
129129
except IndexError:
130130
return None
131131

132-
def keypress(self, size: urwid_Size, key: str) -> str:
132+
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
133133
if is_command_key('SEND_MESSAGE', key):
134134
if self.msg_edit_id:
135135
if not self.to_write_box:
@@ -666,7 +666,7 @@ def mouse_event(self, size: urwid_Size, event: str, button: int,
666666

667667
return super().mouse_event(size, event, button, col, row, focus)
668668

669-
def keypress(self, size: urwid_Size, key: str) -> str:
669+
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
670670
if is_command_key('ENTER', key):
671671
if self.message['type'] == 'private':
672672
self.model.controller.view.write_box.private_box_view(
@@ -790,7 +790,7 @@ def main_view(self) -> Any:
790790
blcorner=u'─', rline=u'', bline=u'─', brcorner=u'─')
791791
return [self.search_bar, self.recipient_bar]
792792

793-
def keypress(self, size: urwid_Size, key: str) -> str:
793+
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
794794
if is_command_key('GO_BACK', key):
795795
self.text_box.set_edit_text("")
796796
self.controller.editor_mode = False
@@ -821,7 +821,7 @@ def __init__(self, panel_view: Any, search_command: str,
821821
urwid.connect_signal(self, 'change', update_function)
822822
super().__init__(edit_text=self.search_text)
823823

824-
def keypress(self, size: urwid_Size, key: str) -> str:
824+
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
825825
if is_command_key('ENTER', key):
826826
self.panel_view.view.controller.editor_mode = False
827827
self.panel_view.set_focus("body")

zulipterminal/ui_tools/buttons.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def activate(self, key: Any) -> None:
7878
self.controller.view.body.focus_col = 1
7979
self.show_function(self)
8080

81-
def keypress(self, size: urwid_Size, key: str) -> str:
81+
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
8282
if is_command_key('ENTER', key):
8383
self.activate(key)
8484
return super().keypress(size, key)
@@ -169,7 +169,7 @@ def mark_unmuted(self) -> None:
169169
# All messages in this stream are read.
170170
self.update_count(0)
171171

172-
def keypress(self, size: urwid_Size, key: str) -> str:
172+
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
173173
if is_command_key('TOGGLE_TOPIC', key):
174174
topic_view = self.view.left_panel.topics_view(self)
175175
self.view.left_panel.is_in_topic_view = True

zulipterminal/ui_tools/views.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ def mouse_event(self, size: urwid_Size, event: str, button: int, col: int,
142142
return True
143143
return super().mouse_event(size, event, button, col, row, focus)
144144

145-
def keypress(self, size: urwid_Size, key: str) -> str:
145+
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
146146
if is_command_key('NEXT_MESSAGE', key) and not self.new_loading:
147147
try:
148148
position = self.log.next_position(self.focus_position)
@@ -290,7 +290,7 @@ def mouse_event(self, size: urwid_Size, event: str, button: int, col: int,
290290
return True
291291
return super().mouse_event(size, event, button, col, row, focus)
292292

293-
def keypress(self, size: urwid_Size, key: str) -> str:
293+
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
294294
if is_command_key('SEARCH_STREAMS', key):
295295
self.set_focus('header')
296296
return key
@@ -377,7 +377,7 @@ def mouse_event(self, size: urwid_Size, event: str, button: int, col: int,
377377
return True
378378
return super().mouse_event(size, event, button, col, row, focus)
379379

380-
def keypress(self, size: urwid_Size, key: str) -> str:
380+
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
381381
if is_command_key('TOGGLE_TOPIC', key):
382382
# Exit topic view
383383
self.view.left_panel.contents[1] = (
@@ -461,7 +461,7 @@ def get_next_unread_pm(self) -> Optional[int]:
461461
return pm
462462
return None
463463

464-
def keypress(self, size: urwid_Size, key: str) -> str:
464+
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
465465
if is_command_key('GO_BACK', key):
466466
self.header.keypress(size, 'esc')
467467
self.footer.keypress(size, 'esc')
@@ -611,7 +611,7 @@ def users_view(self, users: Any=None) -> Any:
611611
self.view.user_w = user_w
612612
return user_w
613613

614-
def keypress(self, size: urwid_Size, key: str) -> str:
614+
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
615615
if is_command_key('SEARCH_PEOPLE', key):
616616
self.allow_update_user_list = False
617617
self.set_focus('header')
@@ -735,7 +735,7 @@ def topics_view(self, stream_button: Any) -> Any:
735735
)
736736
return w
737737

738-
def keypress(self, size: urwid_Size, key: str) -> str:
738+
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
739739
if (is_command_key('SEARCH_STREAMS', key) or
740740
is_command_key('SEARCH_TOPICS', key)):
741741
self.focus_position = 1

0 commit comments

Comments
 (0)