From df4e244bae0f864f8fae2af3fe42a6e81bb330ea Mon Sep 17 00:00:00 2001 From: Max R Date: Wed, 25 Sep 2024 05:57:09 -0400 Subject: [PATCH] Update type definition for `words` argument in completers (#1889) Accept `Sequence` instead of `list`. --- src/prompt_toolkit/completion/fuzzy_completer.py | 4 ++-- src/prompt_toolkit/completion/word_completer.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/prompt_toolkit/completion/fuzzy_completer.py b/src/prompt_toolkit/completion/fuzzy_completer.py index 25ea8923a..82625ab63 100644 --- a/src/prompt_toolkit/completion/fuzzy_completer.py +++ b/src/prompt_toolkit/completion/fuzzy_completer.py @@ -1,7 +1,7 @@ from __future__ import annotations import re -from typing import Callable, Iterable, NamedTuple +from typing import Callable, Iterable, NamedTuple, Sequence from prompt_toolkit.document import Document from prompt_toolkit.filters import FilterOrBool, to_filter @@ -187,7 +187,7 @@ class FuzzyWordCompleter(Completer): def __init__( self, - words: list[str] | Callable[[], list[str]], + words: Sequence[str] | Callable[[], Sequence[str]], meta_dict: dict[str, str] | None = None, WORD: bool = False, ) -> None: diff --git a/src/prompt_toolkit/completion/word_completer.py b/src/prompt_toolkit/completion/word_completer.py index 6ef4031fa..2e124056b 100644 --- a/src/prompt_toolkit/completion/word_completer.py +++ b/src/prompt_toolkit/completion/word_completer.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Callable, Iterable, Mapping, Pattern +from typing import Callable, Iterable, Mapping, Pattern, Sequence from prompt_toolkit.completion import CompleteEvent, Completer, Completion from prompt_toolkit.document import Document @@ -33,7 +33,7 @@ class WordCompleter(Completer): def __init__( self, - words: list[str] | Callable[[], list[str]], + words: Sequence[str] | Callable[[], Sequence[str]], ignore_case: bool = False, display_dict: Mapping[str, AnyFormattedText] | None = None, meta_dict: Mapping[str, AnyFormattedText] | None = None,