mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix flake8 and mypy violations
This commit is contained in:
parent
b0a2e5cf04
commit
86eeee5031
@ -119,7 +119,7 @@ class toctree(nodes.General, nodes.Element, translatable):
|
|||||||
# Domain-specific object descriptions (class, function etc.)
|
# Domain-specific object descriptions (class, function etc.)
|
||||||
#############################################################
|
#############################################################
|
||||||
|
|
||||||
class _desc_classes_injector:
|
class _desc_classes_injector(nodes.TextElement):
|
||||||
"""Helper base class for injecting a fixes list of classes.
|
"""Helper base class for injecting a fixes list of classes.
|
||||||
|
|
||||||
Use as the first base class.
|
Use as the first base class.
|
||||||
@ -127,7 +127,7 @@ class _desc_classes_injector:
|
|||||||
|
|
||||||
classes = [] # type: List[str]
|
classes = [] # type: List[str]
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs) -> None:
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self['classes'].extend(self.classes)
|
self['classes'].extend(self.classes)
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ class desc_inline(_desc_classes_injector, nodes.Inline, nodes.TextElement):
|
|||||||
"""
|
"""
|
||||||
classes = ['sig', 'sig-inline']
|
classes = ['sig', 'sig-inline']
|
||||||
|
|
||||||
def __init__(self, domain: str, *args, **kwargs):
|
def __init__(self, domain: str, *args: Any, **kwargs: Any) -> None:
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self['classes'].append(domain)
|
self['classes'].append(domain)
|
||||||
|
|
||||||
@ -226,7 +226,8 @@ class desc_addname(_desc_classes_injector, nodes.Part, nodes.Inline, nodes.Fixed
|
|||||||
|
|
||||||
This node always has the class ``sig-prename``.
|
This node always has the class ``sig-prename``.
|
||||||
"""
|
"""
|
||||||
classes = ['sig-prename', 'descclassname'] # 'descclassname' is for backwards compatibility
|
# 'descclassname' is for backwards compatibility
|
||||||
|
classes = ['sig-prename', 'descclassname']
|
||||||
|
|
||||||
|
|
||||||
# compatibility alias
|
# compatibility alias
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
from typing import (Any, Callable, Dict, Generator, Iterator, List, Optional, Tuple, Type,
|
from typing import (Any, Callable, Dict, Generator, Iterator, List, Optional, Tuple,
|
||||||
TypeVar, Union, cast)
|
TypeVar, Union, cast)
|
||||||
|
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
@ -1623,9 +1623,9 @@ class ASTOperator(ASTBase):
|
|||||||
symbol: "Symbol") -> None:
|
symbol: "Symbol") -> None:
|
||||||
verify_description_mode(mode)
|
verify_description_mode(mode)
|
||||||
if mode == 'lastIsName':
|
if mode == 'lastIsName':
|
||||||
identnode = addnodes.desc_name()
|
mainName = addnodes.desc_name()
|
||||||
self._describe_identifier(identnode, identnode, env, symbol)
|
self._describe_identifier(mainName, mainName, env, symbol)
|
||||||
signode += identnode
|
signode += mainName
|
||||||
elif mode == 'markType':
|
elif mode == 'markType':
|
||||||
targetText = prefix + str(self) + templateArgs
|
targetText = prefix + str(self) + templateArgs
|
||||||
pnode = addnodes.pending_xref('', refdomain='cpp',
|
pnode = addnodes.pending_xref('', refdomain='cpp',
|
||||||
@ -1637,15 +1637,15 @@ class ASTOperator(ASTBase):
|
|||||||
# and make that the a link to this operator.
|
# and make that the a link to this operator.
|
||||||
# E.g., if it is 'operator SomeType', then 'SomeType' becomes
|
# E.g., if it is 'operator SomeType', then 'SomeType' becomes
|
||||||
# a link to the operator, not to 'SomeType'.
|
# a link to the operator, not to 'SomeType'.
|
||||||
identnode = nodes.literal()
|
container = nodes.literal()
|
||||||
self._describe_identifier(signode, identnode, env, symbol)
|
self._describe_identifier(signode, container, env, symbol)
|
||||||
txt = identnode.astext()
|
txt = container.astext()
|
||||||
pnode += addnodes.desc_name(txt, txt)
|
pnode += addnodes.desc_name(txt, txt)
|
||||||
signode += pnode
|
signode += pnode
|
||||||
else:
|
else:
|
||||||
identnode = addnodes.desc_addname()
|
addName = addnodes.desc_addname()
|
||||||
self._describe_identifier(identnode, identnode, env, symbol)
|
self._describe_identifier(addName, addName, env, symbol)
|
||||||
signode += identnode
|
signode += addName
|
||||||
|
|
||||||
|
|
||||||
class ASTOperatorBuildIn(ASTOperator):
|
class ASTOperatorBuildIn(ASTOperator):
|
||||||
@ -7690,8 +7690,8 @@ class CPPDomain(Domain):
|
|||||||
# and reconstruct the title again
|
# and reconstruct the title again
|
||||||
contnode += nodes.Text(title)
|
contnode += nodes.Text(title)
|
||||||
res = make_refnode(builder, fromdocname, docname,
|
res = make_refnode(builder, fromdocname, docname,
|
||||||
declaration.get_newest_id(), contnode, displayName
|
declaration.get_newest_id(), contnode, displayName
|
||||||
), declaration.objectType
|
), declaration.objectType
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def resolve_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
def resolve_xref(self, env: BuildEnvironment, fromdocname: str, builder: Builder,
|
||||||
|
Loading…
Reference in New Issue
Block a user