From 6340832763f504e41bfff550ac65fd69c7763036 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Sat, 5 Feb 2022 21:26:59 +0300 Subject: [PATCH 1/3] Improve `readline` typings --- stdlib/readline.pyi | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/stdlib/readline.pyi b/stdlib/readline.pyi index fd3a4b1dcc65..facc6a78d017 100644 --- a/stdlib/readline.pyi +++ b/stdlib/readline.pyi @@ -3,8 +3,9 @@ from _typeshed import StrOrBytesPath from typing import Callable, Optional, Sequence if sys.platform != "win32": - _CompleterT = Optional[Callable[[str, int], Optional[str]]] - _CompDispT = Optional[Callable[[str, Sequence[str], int], None]] + _CompleterT = Callable[[str, int], str | None] | None + _CompDispT = Callable[[str, Sequence[str], int], None] | None + def parse_and_bind(__string: str) -> None: ... def read_init_file(__filename: StrOrBytesPath | None = ...) -> None: ... def get_line_buffer() -> str: ... @@ -22,8 +23,8 @@ if sys.platform != "win32": def replace_history_item(__pos: int, __line: str) -> None: ... def add_history(__string: str) -> None: ... def set_auto_history(__enabled: bool) -> None: ... - def set_startup_hook(__function: Callable[[], None] | None = ...) -> None: ... - def set_pre_input_hook(__function: Callable[[], None] | None = ...) -> None: ... + def set_startup_hook(__function: Callable[[], object] | None = ...) -> None: ... + def set_pre_input_hook(__function: Callable[[], object] | None = ...) -> None: ... def set_completer(__function: _CompleterT = ...) -> None: ... def get_completer() -> _CompleterT: ... def get_completion_type() -> int: ... From 8332c622da3e21c0c4ceb400304154e534d5c9ad Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Sat, 5 Feb 2022 21:33:07 +0300 Subject: [PATCH 2/3] Update readline.pyi --- stdlib/readline.pyi | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stdlib/readline.pyi b/stdlib/readline.pyi index facc6a78d017..c2477e0a660f 100644 --- a/stdlib/readline.pyi +++ b/stdlib/readline.pyi @@ -1,10 +1,10 @@ import sys from _typeshed import StrOrBytesPath -from typing import Callable, Optional, Sequence +from typing import Callable, Sequence if sys.platform != "win32": - _CompleterT = Callable[[str, int], str | None] | None - _CompDispT = Callable[[str, Sequence[str], int], None] | None + _CompleterT = Callable[[str, int], str | None] + _CompDispT = Callable[[str, Sequence[str], int], None] def parse_and_bind(__string: str) -> None: ... def read_init_file(__filename: StrOrBytesPath | None = ...) -> None: ... @@ -25,11 +25,11 @@ if sys.platform != "win32": def set_auto_history(__enabled: bool) -> None: ... def set_startup_hook(__function: Callable[[], object] | None = ...) -> None: ... def set_pre_input_hook(__function: Callable[[], object] | None = ...) -> None: ... - def set_completer(__function: _CompleterT = ...) -> None: ... - def get_completer() -> _CompleterT: ... + def set_completer(__function: _CompleterT | None = ...) -> None: ... + def get_completer() -> _CompleterT | None: ... def get_completion_type() -> int: ... def get_begidx() -> int: ... def get_endidx() -> int: ... def set_completer_delims(__string: str) -> None: ... def get_completer_delims() -> str: ... - def set_completion_display_matches_hook(__function: _CompDispT = ...) -> None: ... + def set_completion_display_matches_hook(__function: _CompDispT | None = ...) -> None: ... From f8a67f87195ab47926a28d0b009ba5effc8c16e6 Mon Sep 17 00:00:00 2001 From: Nikita Sobolev Date: Sun, 6 Feb 2022 09:44:09 +0300 Subject: [PATCH 3/3] Update readline.pyi --- stdlib/readline.pyi | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/stdlib/readline.pyi b/stdlib/readline.pyi index c2477e0a660f..df08a3cc25ff 100644 --- a/stdlib/readline.pyi +++ b/stdlib/readline.pyi @@ -3,8 +3,8 @@ from _typeshed import StrOrBytesPath from typing import Callable, Sequence if sys.platform != "win32": - _CompleterT = Callable[[str, int], str | None] - _CompDispT = Callable[[str, Sequence[str], int], None] + _Completer = Callable[[str, int], str | None] + _CompDisp = Callable[[str, Sequence[str], int], None] def parse_and_bind(__string: str) -> None: ... def read_init_file(__filename: StrOrBytesPath | None = ...) -> None: ... @@ -25,11 +25,11 @@ if sys.platform != "win32": def set_auto_history(__enabled: bool) -> None: ... def set_startup_hook(__function: Callable[[], object] | None = ...) -> None: ... def set_pre_input_hook(__function: Callable[[], object] | None = ...) -> None: ... - def set_completer(__function: _CompleterT | None = ...) -> None: ... - def get_completer() -> _CompleterT | None: ... + def set_completer(__function: _Completer | None = ...) -> None: ... + def get_completer() -> _Completer | None: ... def get_completion_type() -> int: ... def get_begidx() -> int: ... def get_endidx() -> int: ... def set_completer_delims(__string: str) -> None: ... def get_completer_delims() -> str: ... - def set_completion_display_matches_hook(__function: _CompDispT | None = ...) -> None: ... + def set_completion_display_matches_hook(__function: _CompDisp | None = ...) -> None: ...