Skip to content

Commit

Permalink
Merge pull request #9064 from tk0miya/refactor_type_annotation
Browse files Browse the repository at this point in the history
refactor: Add Optional to type annotations
  • Loading branch information
tk0miya committed Apr 8, 2021
2 parents 01cac59 + d3f0de4 commit 3ad1e5e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
3 changes: 1 addition & 2 deletions sphinx/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,7 @@ def add_config_value(self, name: str, default: Any, rebuild: Union[bool, str],
``'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)
Expand Down
2 changes: 1 addition & 1 deletion sphinx/builders/_epub_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ def fix_ids(self, tree: nodes.document) -> None:
"""
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:
Expand Down
2 changes: 1 addition & 1 deletion sphinx/ext/autosummary/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 3 additions & 2 deletions sphinx/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
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
Expand Down Expand Up @@ -286,7 +287,7 @@ def create_source_parser(self, app: "Sphinx", filename: str) -> Parser:
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)

Expand Down
2 changes: 1 addition & 1 deletion sphinx/util/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__', []):
Expand Down

0 comments on commit 3ad1e5e

Please sign in to comment.