diff options
| author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2024-05-22 18:38:32 (GMT) |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-22 18:38:32 (GMT) |
| commit | cd39da75afbede2e5f012065fedd709bf74a9c5f (patch) | |
| tree | 30f1870989460378aa6c9ade443ed6b3ceda936d /Lib/_pyrepl/unix_console.py | |
| parent | bfd9c3ea5336f2898e3c58e0c3999bfc25d7da89 (diff) | |
| download | cpython-cd39da75afbede2e5f012065fedd709bf74a9c5f.zip cpython-cd39da75afbede2e5f012065fedd709bf74a9c5f.tar.gz cpython-cd39da75afbede2e5f012065fedd709bf74a9c5f.tar.bz2 | |
[3.13] Improve `pyrepl` type-annotation coverage (GH-119081) (#119415)
(cherry picked from commit 033f5c87f1f876088701d1ae078dc39c41177d4a)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Diffstat (limited to 'Lib/_pyrepl/unix_console.py')
| -rw-r--r-- | Lib/_pyrepl/unix_console.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/Lib/_pyrepl/unix_console.py b/Lib/_pyrepl/unix_console.py index c213012..ec7d063 100644 --- a/Lib/_pyrepl/unix_console.py +++ b/Lib/_pyrepl/unix_console.py @@ -40,9 +40,13 @@ from .unix_eventqueue import EventQueue from .utils import wlen +TYPE_CHECKING = False + # types -if False: - from typing import IO +if TYPE_CHECKING: + from typing import IO, Literal, overload +else: + overload = lambda func: None class InvalidTerminal(RuntimeError): @@ -157,7 +161,13 @@ class UnixConsole(Console): curses.setupterm(term or None, self.output_fd) self.term = term - def _my_getstr(cap, optional=0): + @overload + def _my_getstr(cap: str, optional: Literal[False] = False) -> bytes: ... + + @overload + def _my_getstr(cap: str, optional: bool) -> bytes | None: ... + + def _my_getstr(cap: str, optional: bool = False) -> bytes | None: r = curses.tigetstr(cap) if not optional and r is None: raise InvalidTerminal( @@ -672,18 +682,18 @@ class UnixConsole(Console): elif dy < 0: self.__write_code(self._cuu, -dy) - def __move_x_hpa(self, x): + def __move_x_hpa(self, x: int) -> None: if x != self.__posxy[0]: self.__write_code(self._hpa, x) - def __move_x_cub1_cuf1(self, x): + def __move_x_cub1_cuf1(self, x: int) -> None: dx = x - self.__posxy[0] if dx > 0: self.__write_code(self._cuf1 * dx) elif dx < 0: self.__write_code(self._cub1 * (-dx)) - def __move_x_cub_cuf(self, x): + def __move_x_cub_cuf(self, x: int) -> None: dx = x - self.__posxy[0] if dx > 0: self.__write_code(self._cuf, dx) |
