Migrate to py3 style type annotation: sphinx.builders.latex.util

This commit is contained in:
Takeshi KOMIYA 2019-06-09 00:38:31 +09:00
parent f9a74b08f9
commit f442de643b

View File

@ -18,30 +18,25 @@ from sphinx.deprecation import RemovedInSphinx30Warning
class ExtBabel(Babel): class ExtBabel(Babel):
cyrillic_languages = ('bulgarian', 'kazakh', 'mongolian', 'russian', 'ukrainian') cyrillic_languages = ('bulgarian', 'kazakh', 'mongolian', 'russian', 'ukrainian')
def __init__(self, language_code, use_polyglossia=False): def __init__(self, language_code: str, use_polyglossia: bool = False) -> None:
# type: (str, bool) -> None
self.language_code = language_code self.language_code = language_code
self.use_polyglossia = use_polyglossia self.use_polyglossia = use_polyglossia
self.supported = True self.supported = True
super().__init__(language_code or '') super().__init__(language_code or '')
def get_shorthandoff(self): def get_shorthandoff(self) -> str:
# type: () -> str
warnings.warn('ExtBabel.get_shorthandoff() is deprecated.', warnings.warn('ExtBabel.get_shorthandoff() is deprecated.',
RemovedInSphinx30Warning, stacklevel=2) RemovedInSphinx30Warning, stacklevel=2)
from sphinx.writers.latex import SHORTHANDOFF from sphinx.writers.latex import SHORTHANDOFF
return SHORTHANDOFF return SHORTHANDOFF
def uses_cyrillic(self): def uses_cyrillic(self) -> bool:
# type: () -> bool
return self.language in self.cyrillic_languages return self.language in self.cyrillic_languages
def is_supported_language(self): def is_supported_language(self) -> bool:
# type: () -> bool
return self.supported return self.supported
def language_name(self, language_code): def language_name(self, language_code: str) -> str:
# type: (str) -> str
language = super().language_name(language_code) language = super().language_name(language_code)
if language == 'ngerman' and self.use_polyglossia: if language == 'ngerman' and self.use_polyglossia:
# polyglossia calls new orthography (Neue Rechtschreibung) as # polyglossia calls new orthography (Neue Rechtschreibung) as
@ -55,8 +50,7 @@ class ExtBabel(Babel):
self.supported = False self.supported = False
return 'english' # fallback to english return 'english' # fallback to english
def get_mainlanguage_options(self): def get_mainlanguage_options(self) -> str:
# type: () -> str
"""Return options for polyglossia's ``\\setmainlanguage``.""" """Return options for polyglossia's ``\\setmainlanguage``."""
if self.use_polyglossia is False: if self.use_polyglossia is False:
return None return None