diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 2c3b6028b..22080c95b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -34,6 +34,7 @@ jobs: run: | uvx --with . --with pytest coverage run -m pytest tests/ - name: Type Checking + if: ${{ matrix.python-version != '3.8' }} run: | uvx --with . --with asyncssh mypy --strict src/ --platform win32 uvx --with . --with asyncssh mypy --strict src/ --platform linux diff --git a/src/prompt_toolkit/contrib/telnet/server.py b/src/prompt_toolkit/contrib/telnet/server.py index 69e9a88ad..bc2ad5306 100644 --- a/src/prompt_toolkit/contrib/telnet/server.py +++ b/src/prompt_toolkit/contrib/telnet/server.py @@ -244,7 +244,7 @@ def _run_in_terminal(self, func: Callable[[], None]) -> None: # Make sure that when an application was active for this connection, # that we print the text above the application. if self.context: - self.context.run(run_in_terminal, func) # type: ignore + self.context.run(run_in_terminal, func) else: raise RuntimeError("Called _run_in_terminal outside `run_application`.") diff --git a/src/prompt_toolkit/document.py b/src/prompt_toolkit/document.py index df5293e62..c9fbd9a36 100644 --- a/src/prompt_toolkit/document.py +++ b/src/prompt_toolkit/document.py @@ -54,7 +54,7 @@ class _ImmutableLineList(List[str]): def _error(self, *a: object, **kw: object) -> NoReturn: raise NotImplementedError("Attempt to modify an immutable list.") - __setitem__ = _error # type: ignore + __setitem__ = _error append = _error clear = _error extend = _error @@ -62,7 +62,7 @@ def _error(self, *a: object, **kw: object) -> NoReturn: pop = _error remove = _error reverse = _error - sort = _error # type: ignore + sort = _error class _DocumentCache: diff --git a/src/prompt_toolkit/filters/app.py b/src/prompt_toolkit/filters/app.py index b1b7c1bee..b9cc6111c 100644 --- a/src/prompt_toolkit/filters/app.py +++ b/src/prompt_toolkit/filters/app.py @@ -4,7 +4,7 @@ from __future__ import annotations -from typing import TYPE_CHECKING, cast +from typing import TYPE_CHECKING from prompt_toolkit.application.current import get_app from prompt_toolkit.cache import memoized @@ -61,7 +61,7 @@ def has_focus(value: FocusableElement) -> Condition: """ from prompt_toolkit.buffer import Buffer from prompt_toolkit.layout import walk - from prompt_toolkit.layout.containers import Container, Window, to_container + from prompt_toolkit.layout.containers import Window, to_container from prompt_toolkit.layout.controls import UIControl if isinstance(value, str): @@ -94,7 +94,7 @@ def test() -> bool: # focused. current_window = get_app().layout.current_window - for c in walk(cast(Container, value)): + for c in walk(value): if isinstance(c, Window) and c == current_window: return True return False diff --git a/src/prompt_toolkit/key_binding/vi_state.py b/src/prompt_toolkit/key_binding/vi_state.py index 7ec552faa..0543911e3 100644 --- a/src/prompt_toolkit/key_binding/vi_state.py +++ b/src/prompt_toolkit/key_binding/vi_state.py @@ -6,7 +6,7 @@ from prompt_toolkit.clipboard import ClipboardData if TYPE_CHECKING: - from .key_bindings.vi import TextObject + from .bindings.vi import TextObject from .key_processor import KeyPressEvent __all__ = [ diff --git a/src/prompt_toolkit/shortcuts/prompt.py b/src/prompt_toolkit/shortcuts/prompt.py index d0732bc13..fc3fb5562 100644 --- a/src/prompt_toolkit/shortcuts/prompt.py +++ b/src/prompt_toolkit/shortcuts/prompt.py @@ -1474,7 +1474,7 @@ def prompt( def create_confirm_session( - message: str, suffix: str = " (y/n) " + message: AnyFormattedText, suffix: str = " (y/n) " ) -> PromptSession[bool]: """ Create a `PromptSession` object for the 'confirm' function. @@ -1505,7 +1505,7 @@ def _(event: E) -> None: return session -def confirm(message: str = "Confirm?", suffix: str = " (y/n) ") -> bool: +def confirm(message: AnyFormattedText = "Confirm?", suffix: str = " (y/n) ") -> bool: """ Display a confirmation prompt that returns True/False. """