Migrate to py3 style type annotation: sphinx.util.stemmer

This commit is contained in:
Takeshi KOMIYA 2019-06-05 01:50:22 +09:00
parent 1659cc264c
commit ffe5e129c3

View File

@ -18,18 +18,15 @@ except ImportError:
class BaseStemmer:
def stem(self, word):
# type: (str) -> str
def stem(self, word: str) -> str:
raise NotImplementedError()
class PyStemmer(BaseStemmer):
def __init__(self):
# type: () -> None
def __init__(self) -> None:
self.stemmer = _PyStemmer('porter')
def stem(self, word):
# type: (str) -> str
def stem(self, word: str) -> str:
return self.stemmer.stemWord(word)
@ -37,13 +34,11 @@ class StandardStemmer(PorterStemmer, BaseStemmer): # type: ignore
"""All those porter stemmer implementations look hideous;
make at least the stem method nicer.
"""
def stem(self, word): # type: ignore
# type: (str) -> str
def stem(self, word: str) -> str: # type: ignore
return super().stem(word, 0, len(word) - 1)
def get_stemmer():
# type: () -> BaseStemmer
def get_stemmer() -> BaseStemmer:
if PYSTEMMER:
return PyStemmer()
else: