From 3fa466b7284b2b3d9629efb40feeae2854a94709 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 24 Mar 2019 15:36:05 +0900 Subject: [PATCH] Update type annotations for python domain --- sphinx/directives/__init__.py | 2 +- sphinx/domains/python.py | 13 ++++++------- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/sphinx/directives/__init__.py b/sphinx/directives/__init__.py index fd7bec586..40f838c48 100644 --- a/sphinx/directives/__init__.py +++ b/sphinx/directives/__init__.py @@ -166,7 +166,7 @@ class ObjectDescription(SphinxDirective): node['objtype'] = node['desctype'] = self.objtype node['noindex'] = noindex = ('noindex' in self.options) - self.names = [] # type: List[str] + self.names = [] # type: List[Any] signatures = self.get_signatures() for i, sig in enumerate(signatures): # add a signature node for each signature in the current unit diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py index ea71aa976..b92794ddc 100644 --- a/sphinx/domains/python.py +++ b/sphinx/domains/python.py @@ -317,14 +317,13 @@ class PyObject(ObjectDescription): return fullname, prefix def get_index_text(self, modname, name): - # type: (str, str) -> str + # type: (str, Tuple[str, str]) -> str """Return the text for the index entry of the object.""" raise NotImplementedError('must be implemented in subclasses') def add_target_and_index(self, name_cls, sig, signode): - # type: (str, str, addnodes.desc_signature) -> None - modname = self.options.get( - 'module', self.env.ref_context.get('py:module')) + # type: (Tuple[str, str], str, addnodes.desc_signature) -> None + modname = self.options.get('module', self.env.ref_context.get('py:module')) fullname = (modname and modname + '.' or '') + name_cls[0] # note target if fullname not in self.state.document.ids: @@ -418,7 +417,7 @@ class PyModulelevel(PyObject): return self.objtype == 'function' def get_index_text(self, modname, name_cls): - # type: (str, str) -> str + # type: (str, Tuple[str, str]) -> str if self.objtype == 'function': if not modname: return _('%s() (built-in function)') % name_cls[0] @@ -443,7 +442,7 @@ class PyClasslike(PyObject): return self.objtype + ' ' def get_index_text(self, modname, name_cls): - # type: (str, str) -> str + # type: (str, Tuple[str, str]) -> str if self.objtype == 'class': if not modname: return _('%s (built-in class)') % name_cls[0] @@ -472,7 +471,7 @@ class PyClassmember(PyObject): return '' def get_index_text(self, modname, name_cls): - # type: (str, str) -> str + # type: (str, Tuple[str, str]) -> str name, cls = name_cls add_modules = self.env.config.add_module_names if self.objtype == 'method':