Skip to content

Commit

Permalink
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.
  • Loading branch information
pmhahn committed Jun 1, 2023
1 parent dcb2c5e commit c5f9502
Show file tree
Hide file tree
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
Expand Up @@ -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

Expand Down Expand Up @@ -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()
Expand Down
3 changes: 2 additions & 1 deletion enchant/checker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c5f9502

Please sign in to comment.