diff options
| author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-07-13 11:17:35 +0900 |
|---|---|---|
| committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2019-07-13 11:17:35 +0900 |
| commit | a498960de9039b0d0c8d24f75f32fa4acd5b75e1 (patch) | |
| tree | d705e2adcb43ca51c18600b9d3933e5fa9b9c5b1 /sphinx/util | |
| parent | 199ebaa94b94042e20146119babba9c7c767bb99 (diff) | |
| parent | 9a552a9cd785e979eda3ab2afa3d36777cce833d (diff) | |
| download | sphinx-git-a498960de9039b0d0c8d24f75f32fa4acd5b75e1.tar.gz | |
Merge branch '2.0'
Diffstat (limited to 'sphinx/util')
| -rw-r--r-- | sphinx/util/__init__.py | 2 | ||||
| -rw-r--r-- | sphinx/util/docutils.py | 16 | ||||
| -rw-r--r-- | sphinx/util/inspect.py | 8 |
3 files changed, 13 insertions, 13 deletions
diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index 7bfb3ad3e..0d54e1482 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -220,7 +220,7 @@ def save_traceback(app: "Sphinx") -> str: platform.python_version(), platform.python_implementation(), docutils.__version__, docutils.__version_details__, - jinja2.__version__, # type: ignore + jinja2.__version__, last_msgs)).encode()) if app is not None: for ext in app.extensions.values(): diff --git a/sphinx/util/docutils.py b/sphinx/util/docutils.py index 25010c41f..66fcc3374 100644 --- a/sphinx/util/docutils.py +++ b/sphinx/util/docutils.py @@ -49,13 +49,13 @@ additional_nodes = set() # type: Set[Type[nodes.Element]] def docutils_namespace() -> Generator[None, None, None]: """Create namespace for reST parsers.""" try: - _directives = copy(directives._directives) # type: ignore - _roles = copy(roles._roles) # type: ignore + _directives = copy(directives._directives) + _roles = copy(roles._roles) yield finally: - directives._directives = _directives # type: ignore - roles._roles = _roles # type: ignore + directives._directives = _directives + roles._roles = _roles for node in list(additional_nodes): unregister_node(node) @@ -64,7 +64,7 @@ def docutils_namespace() -> Generator[None, None, None]: def is_directive_registered(name: str) -> bool: """Check the *name* directive is already registered.""" - return name in directives._directives # type: ignore + return name in directives._directives def register_directive(name: str, directive: Type[Directive]) -> None: @@ -78,7 +78,7 @@ def register_directive(name: str, directive: Type[Directive]) -> None: def is_role_registered(name: str) -> bool: """Check the *name* role is already registered.""" - return name in roles._roles # type: ignore + return name in roles._roles def register_role(name: str, role: RoleFunction) -> None: @@ -92,7 +92,7 @@ def register_role(name: str, role: RoleFunction) -> None: def unregister_role(name: str) -> None: """Unregister a role from docutils.""" - roles._roles.pop(name, None) # type: ignore + roles._roles.pop(name, None) def is_node_registered(node: Type[Element]) -> bool: @@ -107,7 +107,7 @@ def register_node(node: Type[Element]) -> None: inside ``docutils_namespace()`` to prevent side-effects. """ if not hasattr(nodes.GenericNodeVisitor, 'visit_' + node.__name__): - nodes._add_node_class_names([node.__name__]) # type: ignore + nodes._add_node_class_names([node.__name__]) additional_nodes.add(node) diff --git a/sphinx/util/inspect.py b/sphinx/util/inspect.py index fc6dafe9f..66bb950c6 100644 --- a/sphinx/util/inspect.py +++ b/sphinx/util/inspect.py @@ -514,7 +514,7 @@ class Signature: qualname = repr(annotation) if (hasattr(typing, 'TupleMeta') and - isinstance(annotation, typing.TupleMeta) and # type: ignore + isinstance(annotation, typing.TupleMeta) and not hasattr(annotation, '__tuple_params__')): # This is for Python 3.6+, 3.5 case is handled below params = annotation.__args__ @@ -545,7 +545,7 @@ class Signature: param_str = ', '.join(self.format_annotation(p) for p in params) return '%s[%s]' % (qualname, param_str) elif (hasattr(typing, 'UnionMeta') and # for py35 or below - isinstance(annotation, typing.UnionMeta) and # type: ignore + isinstance(annotation, typing.UnionMeta) and hasattr(annotation, '__union_params__')): params = annotation.__union_params__ if params is not None: @@ -565,7 +565,7 @@ class Signature: param_str = ', '.join(self.format_annotation(p) for p in params) return 'Union[%s]' % param_str elif (hasattr(typing, 'CallableMeta') and # for py36 or below - isinstance(annotation, typing.CallableMeta) and # type: ignore + isinstance(annotation, typing.CallableMeta) and getattr(annotation, '__args__', None) is not None and hasattr(annotation, '__result__')): # Skipped in the case of plain typing.Callable @@ -581,7 +581,7 @@ class Signature: args_str, self.format_annotation(annotation.__result__)) elif (hasattr(typing, 'TupleMeta') and # for py36 or below - isinstance(annotation, typing.TupleMeta) and # type: ignore + isinstance(annotation, typing.TupleMeta) and hasattr(annotation, '__tuple_params__') and hasattr(annotation, '__tuple_use_ellipsis__')): params = annotation.__tuple_params__ |
