Skip to content

Commit 212c72e

Browse files
Improved a few type annotations.
1 parent d45f098 commit 212c72e

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

prompt_toolkit/application/dummy.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Callable, Optional
1+
from typing import Callable, Optional
22

33
from prompt_toolkit.input import DummyInput
44
from prompt_toolkit.output import DummyOutput
@@ -10,7 +10,7 @@
1010
]
1111

1212

13-
class DummyApplication(Application):
13+
class DummyApplication(Application[None]):
1414
"""
1515
When no :class:`.Application` is running,
1616
:func:`.get_app` will run an instance of this :class:`.DummyApplication` instead.
@@ -19,10 +19,10 @@ def __init__(self) -> None:
1919
super().__init__(output=DummyOutput(), input=DummyInput())
2020

2121
def run(self, pre_run: Optional[Callable[[], None]] = None,
22-
set_exception_handler: bool = True) -> Any:
22+
set_exception_handler: bool = True) -> None:
2323
raise NotImplementedError('A DummyApplication is not supposed to run.')
2424

25-
async def run_async(self, pre_run: Optional[Callable[[], None]] = None) -> Any:
25+
async def run_async(self, pre_run: Optional[Callable[[], None]] = None) -> None:
2626
raise NotImplementedError('A DummyApplication is not supposed to run.')
2727

2828
async def run_system_command(

prompt_toolkit/layout/controls.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
from abc import ABCMeta, abstractmethod
66
from typing import (
77
TYPE_CHECKING,
8-
Any,
98
Callable,
109
Dict,
10+
Hashable,
1111
Iterable,
1212
List,
1313
NamedTuple,
@@ -175,7 +175,7 @@ def __init__(self,
175175
self.show_cursor = show_cursor
176176

177177
# Cache for line heights. Maps cache key -> height
178-
self._line_heights_cache: Dict[Any, int] = {}
178+
self._line_heights_cache: Dict[Hashable, int] = {}
179179

180180
def __getitem__(self, lineno: int) -> StyleAndTextTuples:
181181
" Make it iterable (iterate line by line). "
@@ -317,7 +317,7 @@ def __init__(
317317
self.get_cursor_position = get_cursor_position
318318

319319
#: Cache for the content.
320-
self._content_cache: SimpleCache[Any, UIContent] = SimpleCache(maxsize=18)
320+
self._content_cache: SimpleCache[Hashable, UIContent] = SimpleCache(maxsize=18)
321321
self._fragment_cache: SimpleCache[int, StyleAndTextTuples] = SimpleCache(maxsize=1)
322322
# Only cache one fragment list. We don't need the previous item.
323323

@@ -533,7 +533,7 @@ def __init__(
533533
#: Often, due to cursor movement, undo/redo and window resizing
534534
#: operations, it happens that a short time, the same document has to be
535535
#: lexed. This is a fairly easy way to cache such an expensive operation.
536-
self._fragment_cache: SimpleCache[Any, Callable[[int], StyleAndTextTuples]] = \
536+
self._fragment_cache: SimpleCache[Hashable, Callable[[int], StyleAndTextTuples]] = \
537537
SimpleCache(maxsize=8)
538538

539539
self._last_click_timestamp: Optional[float] = None

prompt_toolkit/renderer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ def __init__(
311311
self._bracketed_paste_enabled = False
312312

313313
# Future set when we are waiting for a CPR flag.
314-
self._waiting_for_cpr_futures: Deque[Future] = deque()
314+
self._waiting_for_cpr_futures: Deque[Future[None]] = deque()
315315
self.cpr_support = CPR_Support.UNKNOWN
316316
if not input.responds_to_cpr:
317317
self.cpr_support = CPR_Support.NOT_SUPPORTED

0 commit comments

Comments
 (0)