Compare commits

...

4 commits

Author SHA1 Message Date
7bd91b677c
Merge branch 'dmitmel-master' 2021-06-04 22:18:44 +02:00
0036ca29c8
[Chore] Fix merge conflict. 2021-06-04 22:18:27 +02:00
Dmytro Meleshko
bf230c414e [nvim] add a few little tricks found in romainl's Gists 2021-06-04 20:08:07 +03:00
Dmytro Meleshko
b0f7307999 [python] enable strict typechecking 2021-06-04 20:08:02 +03:00

View file

@ -13,7 +13,11 @@ def platform_not_supported_error() -> NoReturn:
raise Exception("platform '{}' is not supported!".format(sys.platform)) raise Exception("platform '{}' is not supported!".format(sys.platform))
def run_chooser(choices: Iterable[str], prompt: Optional[str] = None, async_read: bool = False) -> int: def run_chooser(
choices: Iterable[str],
prompt: Optional[str] = None,
async_read: bool = False,
) -> int:
supports_result_index = True supports_result_index = True
if os.isatty(sys.stderr.fileno()): if os.isatty(sys.stderr.fileno()):
process_args = [ process_args = [
@ -41,7 +45,8 @@ def run_chooser(choices: Iterable[str], prompt: Optional[str] = None, async_read
with chooser_process.stdin as pipe: with chooser_process.stdin as pipe:
for index, choice in enumerate(choices): for index, choice in enumerate(choices):
if "\n" not in choice:
if "\n" in choice:
raise Exception("choices can only span a single line") raise Exception("choices can only span a single line")
if not supports_result_index: if not supports_result_index:
pipe.write(str(index).encode()) pipe.write(str(index).encode())