Skip to content

Commit ab55821

Browse files
committed
doc(checker): PEP-484 get_text -> Any
get_text() -> Union[str, array] depends on what was used when set_text() was used. Because of <python/mypy#1693> use Any.
1 parent 0a2ffde commit ab55821

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎enchant/checker/GtkSpellCheckerDialog.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# do so, delete this exception statement from your version.
2929
#
3030

31-
from typing import Any, Iterable, List, Optional
31+
from typing import Any, Iterable, List, cast
3232

3333
import gi
3434

@@ -215,7 +215,7 @@ def _getRepl(self) -> str:
215215
"""Get the chosen replacement string."""
216216
repl = self.replace_text.get_text()
217217
repl = self._checker.coerce_string(repl)
218-
return repl
218+
return cast(str, repl)
219219

220220
def _fillSuggestionList(self, suggestions: Iterable[str]) -> None:
221221
model = self.suggestion_list_view.get_model()

‎enchant/checker/__init__.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747

4848
import array
4949
import warnings
50+
from typing import Any
5051
from typing import Dict as PythonDict
5152
from typing import List, Optional, Type, Union
5253

@@ -202,7 +203,7 @@ def set_text(self, text: Union[bytes, str, array.array]) -> None:
202203
raise TypeError(text)
203204
self._tokens = self._tokenize(self._text)
204205

205-
def get_text(self) -> str:
206+
def get_text(self) -> Any:
206207
"""Return the spell-checked text."""
207208
if self._use_tostring:
208209
return self._array_to_string(self._text)

0 commit comments

Comments
 (0)