Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc(checker): PEP-484 get_text -> Any
Browse files Browse the repository at this point in the history
get_text() -> Union[str, array] depends on what was used when
set_text() was used.
Because of <python/mypy#1693> use Any.
pmhahn committed Jun 1, 2023
1 parent 5db7063 commit 9e46d00
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions enchant/checker/GtkSpellCheckerDialog.py
Original file line number Diff line number Diff line change
@@ -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()
3 changes: 2 additions & 1 deletion enchant/checker/__init__.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 9e46d00

Please sign in to comment.