diff options
Diffstat (limited to 'sphinx/ext/autodoc/__init__.py')
-rw-r--r-- | sphinx/ext/autodoc/__init__.py | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index e8fbd3865..35b16673e 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -234,7 +234,7 @@ def between( # But we define this class here to keep compatibility (see #4538) class Options(dict): """A dict/attribute hybrid that returns None on nonexisting keys.""" - def copy(self) -> "Options": + def copy(self) -> Options: return Options(super().copy()) def __getattr__(self, name: str) -> Any: @@ -314,7 +314,7 @@ class Documenter: """Called to see if a member can be documented by this Documenter.""" raise NotImplementedError('must be implemented in subclasses') - def __init__(self, directive: "DocumenterBridge", name: str, indent: str = '') -> None: + def __init__(self, directive: DocumenterBridge, name: str, indent: str = '') -> None: self.directive = directive self.config: Config = directive.env.config self.env: BuildEnvironment = directive.env @@ -340,7 +340,7 @@ class Documenter: self.analyzer: ModuleAnalyzer = None @property - def documenters(self) -> dict[str, type["Documenter"]]: + def documenters(self) -> dict[str, type[Documenter]]: """Returns registered Documenter classes""" return self.env.app.registry.documenters @@ -515,9 +515,9 @@ class Documenter: sourcename = self.get_sourcename() # one signature per line, indented by column - prefix = '.. %s:%s:: ' % (domain, directive) + prefix = f'.. {domain}:{directive}:: ' for i, sig_line in enumerate(sig.split("\n")): - self.add_line('%s%s%s' % (prefix, name, sig_line), + self.add_line(f'{prefix}{name}{sig_line}', sourcename) if i == 0: prefix = " " * len(prefix) @@ -562,12 +562,12 @@ class Documenter: inspect.safe_getattr(self.object, '__qualname__', None)): # Get the correct location of docstring from self.object # to support inherited methods - fullname = '%s.%s' % (self.object.__module__, self.object.__qualname__) + fullname = f'{self.object.__module__}.{self.object.__qualname__}' else: fullname = self.fullname if self.analyzer: - return '%s:docstring of %s' % (self.analyzer.srcname, fullname) + return f'{self.analyzer.srcname}:docstring of {fullname}' else: return 'docstring of %s' % fullname @@ -819,8 +819,8 @@ class Documenter: self.env.temp_data['autodoc:module'] = None self.env.temp_data['autodoc:class'] = None - def sort_members(self, documenters: list[tuple["Documenter", bool]], - order: str) -> list[tuple["Documenter", bool]]: + def sort_members(self, documenters: list[tuple[Documenter, bool]], + order: str) -> list[tuple[Documenter, bool]]: """Sort the given member list.""" if order == 'groupwise': # sort by group; alphabetically within groups @@ -1075,8 +1075,8 @@ class ModuleDocumenter(Documenter): type='autodoc') return False, ret - def sort_members(self, documenters: list[tuple["Documenter", bool]], - order: str) -> list[tuple["Documenter", bool]]: + def sort_members(self, documenters: list[tuple[Documenter, bool]], + order: str) -> list[tuple[Documenter, bool]]: if order == 'bysource' and self.__all__: # Sort alphabetically first (for members not listed on the __all__) documenters.sort(key=lambda e: e[0].name) @@ -1200,7 +1200,7 @@ class DocstringSignatureMixin: result = args, retann else: # subsequent signatures - self._signatures.append("(%s) -> %s" % (args, retann)) + self._signatures.append(f"({args}) -> {retann}") if result: # finish the loop when signature found @@ -1478,7 +1478,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: call = get_user_defined_function_or_method(type(self.object), '__call__') if call is not None: - if "{0.__module__}.{0.__qualname__}".format(call) in _METACLASS_CALL_BLACKLIST: + if f"{call.__module__}.{call.__qualname__}" in _METACLASS_CALL_BLACKLIST: call = None if call is not None: @@ -1494,7 +1494,7 @@ class ClassDocumenter(DocstringSignatureMixin, ModuleLevelDocumenter): # type: new = get_user_defined_function_or_method(self.object, '__new__') if new is not None: - if "{0.__module__}.{0.__qualname__}".format(new) in _CLASS_NEW_BLACKLIST: + if f"{new.__module__}.{new.__qualname__}" in _CLASS_NEW_BLACKLIST: new = None if new is not None: |