mypy: Turn on return value checks

Its a shame GvR is married to "return None"
https://github.com/python/mypy/issues/7511
This commit is contained in:
Kovid Goyal
2021-10-26 22:39:14 +05:30
parent 5cb36a4632
commit 4494ddd8ff
52 changed files with 124 additions and 49 deletions

View File

@@ -106,6 +106,7 @@ def main(args: List[str]) -> Optional[Dict[str, Any]]:
loop = Loop()
handler = Broadcast(opts, items)
loop.loop(handler)
return None
if __name__ == '__main__':

View File

@@ -24,6 +24,7 @@ def find_differ() -> Optional[str]:
return GIT_DIFF
if shutil.which('diff'):
return DIFF_DIFF
return None
def set_diff_command(opt: str) -> None:

View File

@@ -688,6 +688,7 @@ def main(args: List[str]) -> Optional[Dict[str, Any]]:
import traceback
traceback.print_exc()
input(_('Press Enter to quit'))
return None
def linenum_handle_result(args: List[str], data: Dict[str, Any], target_window_id: int, boss: BossType, extra_cli_args: Sequence[str], *a: Any) -> None:

View File

@@ -132,7 +132,7 @@ class ControlMaster:
self.dest = os.path.join(self.tdir, os.path.basename(self.remote_path))
return self
def __exit__(self, *a: Any) -> bool:
def __exit__(self, *a: Any) -> None:
subprocess.Popen(
self.batch_cmd_prefix + ['-O', 'exit', self.conn_data.hostname],
stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL, stdin=subprocess.DEVNULL
@@ -215,6 +215,7 @@ def main(args: List[str]) -> Result:
import traceback
traceback.print_exc()
show_error('Failed with unhandled exception')
return None
def save_as(conn_data: SSHConnectionData, remote_path: str, cli_opts: RemoteFileCLIOptions) -> None:
@@ -312,6 +313,7 @@ def handle_action(action: str, cli_opts: RemoteFileCLIOptions) -> Result:
elif action == 'save':
print('Saving', cli_opts.path, 'from', cli_opts.hostname)
save_as(conn_data, remote_path, cli_opts)
return None
@result_handler()

View File

@@ -203,6 +203,7 @@ class ThemesHandler(Handler):
col = color_as_sharp(color_from_int(o.color_table[i]))
cmds.append(f'{i};{col}')
self.print(end='\033]4;' + ';'.join(cmds) + '\033\\')
return True
def redraw_after_category_change(self) -> None:
self.themes_list.update_themes(self.all_themes.filtered(self.filter_map[self.current_category]))

View File

@@ -312,6 +312,7 @@ class SendManager:
ans = self.files[self.active_idx]
if ans.state is FileState.transmitting:
return ans
return None
def activate_next_ready_file(self) -> Optional[File]:
if self.active_idx is not None:
@@ -325,6 +326,7 @@ class SendManager:
return f
self.active_idx = None
self.update_collective_statuses()
return None
def update_collective_statuses(self) -> None:
found_not_started = found_not_done = False

View File

@@ -83,6 +83,7 @@ class Handler:
for sc, action in self._key_shortcuts.items():
if key_event.matches(sc):
return action
return None
def __enter__(self) -> None:
if self._image_manager is not None:

View File

@@ -132,6 +132,7 @@ class PathCompleter:
options = self.cache[text] = tuple(find_completions(text))
if options and state < len(options):
return options[state]
return None
def __exit__(self, *a: Any) -> bool:
import readline
@@ -143,6 +144,7 @@ class PathCompleter:
def input(self) -> str:
with self:
return input(self.prompt)
return ''
def develop() -> None:

View File

@@ -157,6 +157,7 @@ class Table:
def current_codepoint(self) -> Optional[int]:
if self.codepoints:
return self.codepoints[self.current_idx]
return None
def set_codepoints(self, codepoints: List[int], mode: str = HEX, current_idx: int = 0) -> None:
self.codepoints = codepoints