Skip to content

Various typing fixes #2003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/prompt_toolkit/contrib/telnet/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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`.")

Expand Down
4 changes: 2 additions & 2 deletions src/prompt_toolkit/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ 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
insert = _error
pop = _error
remove = _error
reverse = _error
sort = _error # type: ignore
sort = _error


class _DocumentCache:
Expand Down
6 changes: 3 additions & 3 deletions src/prompt_toolkit/filters/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/prompt_toolkit/key_binding/vi_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = [
Expand Down
4 changes: 2 additions & 2 deletions src/prompt_toolkit/shortcuts/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
"""
Expand Down