diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-02-16 20:32:33 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2020-02-23 19:11:48 +0900 |
commit | ecd9b9379ffe224f59bb86d11de3c9c786d55521 (patch) | |
tree | 13f5d303c80a5fb31b9d7af56ca89c62111f6196 | |
parent | 8df10233696d199983dbba13463829d14705a94e (diff) | |
download | sphinx-git-ecd9b9379ffe224f59bb86d11de3c9c786d55521.tar.gz |
refactor: Update type annotations in sphinx.*
-rw-r--r-- | sphinx/directives/__init__.py | 2 | ||||
-rw-r--r-- | sphinx/directives/other.py | 4 | ||||
-rw-r--r-- | sphinx/locale/__init__.py | 2 | ||||
-rw-r--r-- | sphinx/registry.py | 2 | ||||
-rw-r--r-- | sphinx/transforms/post_transforms/__init__.py | 2 |
5 files changed, 6 insertions, 6 deletions
diff --git a/sphinx/directives/__init__.py b/sphinx/directives/__init__.py index 9436e9759..8f290d62d 100644 --- a/sphinx/directives/__init__.py +++ b/sphinx/directives/__init__.py @@ -36,7 +36,7 @@ nl_escape_re = re.compile(r'\\\n') strip_backslash_re = re.compile(r'\\(.)') -def optional_int(argument): +def optional_int(argument: str) -> int: """ Check for an integer argument or None value; raise ``ValueError`` if not. """ diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py index 87d769b41..e4fcc0f5c 100644 --- a/sphinx/directives/other.py +++ b/sphinx/directives/other.py @@ -85,14 +85,14 @@ class TocTree(SphinxDirective): ret.append(wrappernode) return ret - def parse_content(self, toctree): + def parse_content(self, toctree: addnodes.toctree) -> List[Node]: suffixes = self.config.source_suffix # glob target documents all_docnames = self.env.found_docs.copy() all_docnames.remove(self.env.docname) # remove current document - ret = [] + ret = [] # type: List[Node] excluded = Matcher(self.config.exclude_patterns) for entry in self.content: if not entry: diff --git a/sphinx/locale/__init__.py b/sphinx/locale/__init__.py index 82aefe91e..9812355ca 100644 --- a/sphinx/locale/__init__.py +++ b/sphinx/locale/__init__.py @@ -197,7 +197,7 @@ def _lazy_translate(catalog: str, namespace: str, message: str) -> str: return translator.gettext(message) -def get_translation(catalog, namespace='general'): +def get_translation(catalog: str, namespace: str = 'general') -> Callable: """Get a translation function based on the *catalog* and *namespace*. The extension can use this API to translate the messages on the diff --git a/sphinx/registry.py b/sphinx/registry.py index 04b62575a..9a1d68dd6 100644 --- a/sphinx/registry.py +++ b/sphinx/registry.py @@ -356,7 +356,7 @@ class SphinxComponentRegistry: attrgetter: Callable[[Any, str, Any], Any]) -> None: self.autodoc_attrgettrs[typ] = attrgetter - def add_css_files(self, filename, **attributes): + def add_css_files(self, filename: str, **attributes: str) -> None: self.css_files.append((filename, attributes)) def add_js_file(self, filename: str, **attributes: str) -> None: diff --git a/sphinx/transforms/post_transforms/__init__.py b/sphinx/transforms/post_transforms/__init__.py index ee459cc56..6d7c3b0eb 100644 --- a/sphinx/transforms/post_transforms/__init__.py +++ b/sphinx/transforms/post_transforms/__init__.py @@ -131,7 +131,7 @@ class ReferencesResolver(SphinxPostTransform): if not results: return None if len(results) > 1: - def stringify(name, node): + def stringify(name: str, node: Element) -> str: reftitle = node.get('reftitle', node.astext()) return ':%s:`%s`' % (name, reftitle) candidates = ' or '.join(stringify(name, role) for name, role in results) |