summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2021-04-08 21:42:21 +0900
committerGitHub <noreply@github.com>2021-04-08 21:42:21 +0900
commit3ad1e5e7d1a5fa38e94124e8afc441764a95cdd9 (patch)
tree7124eeb06475b8fd605ee335c49e7c5d853a6846
parent01cac597e3ca6daf2a5a702107e8dd6597090802 (diff)
parentd3f0de4e122aa8213f7d127f75d94311d2bed682 (diff)
downloadsphinx-git-3ad1e5e7d1a5fa38e94124e8afc441764a95cdd9.tar.gz
Merge pull request #9064 from tk0miya/refactor_type_annotation
refactor: Add Optional to type annotations
-rw-r--r--sphinx/application.py3
-rw-r--r--sphinx/builders/_epub_base.py2
-rw-r--r--sphinx/ext/autosummary/generate.py2
-rw-r--r--sphinx/registry.py5
-rw-r--r--sphinx/util/inspect.py2
5 files changed, 7 insertions, 7 deletions
diff --git a/sphinx/application.py b/sphinx/application.py
index ef77e34db..cb91b94fe 100644
--- a/sphinx/application.py
+++ b/sphinx/application.py
@@ -526,8 +526,7 @@ class Sphinx:
``'env'``) to a string. However, booleans are still accepted and
converted internally.
"""
- logger.debug('[app] adding config value: %r',
- (name, default, rebuild) + ((types,) if types else ()))
+ logger.debug('[app] adding config value: %r', (name, default, rebuild, types))
if rebuild in (False, True):
rebuild = 'env' if rebuild else ''
self.config.add(name, default, rebuild, types)
diff --git a/sphinx/builders/_epub_base.py b/sphinx/builders/_epub_base.py
index 65fb1ff9a..103033478 100644
--- a/sphinx/builders/_epub_base.py
+++ b/sphinx/builders/_epub_base.py
@@ -270,7 +270,7 @@ class EpubBuilder(StandaloneHTMLBuilder):
"""
def update_node_id(node: Element) -> None:
"""Update IDs of given *node*."""
- new_ids = []
+ new_ids: List[str] = []
for node_id in node['ids']:
new_id = self.fix_fragment('', node_id)
if new_id not in new_ids:
diff --git a/sphinx/ext/autosummary/generate.py b/sphinx/ext/autosummary/generate.py
index b25d14d72..d1130d096 100644
--- a/sphinx/ext/autosummary/generate.py
+++ b/sphinx/ext/autosummary/generate.py
@@ -407,7 +407,7 @@ def generate_autosummary_docs(sources: List[str], output_dir: str = None,
logger.warning(__('[autosummary] failed to import %r: %s') % (entry.name, e))
continue
- context = {}
+ context: Dict[str, Any] = {}
if app:
context.update(app.config.autosummary_context)
diff --git a/sphinx/registry.py b/sphinx/registry.py
index 028188402..cdf77cb67 100644
--- a/sphinx/registry.py
+++ b/sphinx/registry.py
@@ -12,7 +12,8 @@ import traceback
import warnings
from importlib import import_module
from types import MethodType
-from typing import TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Tuple, Type, Union
+from typing import (TYPE_CHECKING, Any, Callable, Dict, Iterator, List, Optional, Tuple, Type,
+ Union)
from docutils import nodes
from docutils.io import Input
@@ -286,7 +287,7 @@ class SphinxComponentRegistry:
parser.set_application(app)
return parser
- def get_source_input(self, filetype: str) -> Type[Input]:
+ def get_source_input(self, filetype: str) -> Optional[Type[Input]]:
warnings.warn('SphinxComponentRegistry.get_source_input() is deprecated.',
RemovedInSphinx60Warning)
diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py
index 921dbc5e2..96f04a3d3 100644
--- a/sphinx/util/inspect.py
+++ b/sphinx/util/inspect.py
@@ -749,7 +749,7 @@ def getdoc(obj: Any, attrgetter: Callable = safe_getattr,
elif doc is None and allow_inherited:
doc = inspect.getdoc(obj)
- if doc is None and cls:
+ if doc is None and cls and name:
# inspect.getdoc() does not support some kind of inherited and decorated methods.
# This tries to obtain the docstring from super classes.
for basecls in getattr(cls, '__mro__', []):