|
3 | 3 | # This source code is licensed under the MIT license found in the |
4 | 4 | # LICENSE file in the root directory of this source tree. |
5 | 5 | from abc import ABC, abstractmethod |
6 | | -from typing import TYPE_CHECKING, Tuple, Union |
| 6 | +from typing import TYPE_CHECKING, Tuple |
7 | 7 |
|
8 | 8 | if TYPE_CHECKING: |
9 | 9 | import curses |
@@ -39,7 +39,7 @@ def getch(self) -> int: |
39 | 39 | pass |
40 | 40 |
|
41 | 41 | @abstractmethod |
42 | | - def getstr(self, y_pos: int, x_pos: int, max_len: int) -> Union[str, bytes, int]: |
| 42 | + def getstr(self, y_pos: int, x_pos: int, max_len: int) -> str: |
43 | 43 | pass |
44 | 44 |
|
45 | 45 |
|
@@ -68,5 +68,10 @@ def delch(self, y_pos: int, x_pos: int) -> None: |
68 | 68 | def getch(self) -> int: |
69 | 69 | return self.screen.getch() |
70 | 70 |
|
71 | | - def getstr(self, y_pos: int, x_pos: int, max_len: int) -> Union[str, bytes, int]: |
72 | | - return self.screen.getstr(y_pos, x_pos, max_len) |
| 71 | + def getstr(self, y_pos: int, x_pos: int, max_len: int) -> str: |
| 72 | + result = self.screen.getstr(y_pos, x_pos, max_len) |
| 73 | + if isinstance(result, str): |
| 74 | + return result |
| 75 | + if isinstance(result, int): |
| 76 | + return str(result) |
| 77 | + return result.decode("utf-8") |
0 commit comments