From c5f9502ea6e202c19f96d12539ed68e107961eb3 Mon Sep 17 00:00:00 2001 From: Philipp Hahn Date: Tue, 4 Jan 2022 08:04:05 +0100 Subject: [PATCH] doc(checker): PEP-484 get_text -> Any get_text() -> Union[str, array] depends on what was used when set_text() was used. Because of use Any. --- enchant/checker/GtkSpellCheckerDialog.py | 4 ++-- enchant/checker/__init__.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/enchant/checker/GtkSpellCheckerDialog.py b/enchant/checker/GtkSpellCheckerDialog.py index 71a2fb69..fb53af56 100644 --- a/enchant/checker/GtkSpellCheckerDialog.py +++ b/enchant/checker/GtkSpellCheckerDialog.py @@ -28,7 +28,7 @@ # do so, delete this exception statement from your version. # -from typing import Any, Iterable, List, Optional +from typing import Any, Iterable, List, cast import gi @@ -215,7 +215,7 @@ def _getRepl(self) -> str: """Get the chosen replacement string.""" repl = self.replace_text.get_text() repl = self._checker.coerce_string(repl) - return repl + return cast(str, repl) def _fillSuggestionList(self, suggestions: Iterable[str]) -> None: model = self.suggestion_list_view.get_model() diff --git a/enchant/checker/__init__.py b/enchant/checker/__init__.py index c55f0038..f432f007 100644 --- a/enchant/checker/__init__.py +++ b/enchant/checker/__init__.py @@ -47,6 +47,7 @@ import array import warnings +from typing import Any from typing import Dict as PythonDict from typing import List, Optional, Type, Union @@ -202,7 +203,7 @@ def set_text(self, text: Union[bytes, str, array.array]) -> None: raise TypeError(text) self._tokens = self._tokenize(self._text) - def get_text(self) -> str: + def get_text(self) -> Any: """Return the spell-checked text.""" if self._use_tostring: return self._array_to_string(self._text)