From 9a636683a0a3aebdbf82091a59d8bf9bd112d6b4 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sun, 4 Nov 2018 23:42:27 +0900 Subject: [PATCH] Fix typehints: sphinx.util.math --- sphinx/ext/jsmath.py | 3 ++- sphinx/ext/mathjax.py | 3 ++- sphinx/util/math.py | 10 ++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sphinx/ext/jsmath.py b/sphinx/ext/jsmath.py index 3babd408e..e03351800 100644 --- a/sphinx/ext/jsmath.py +++ b/sphinx/ext/jsmath.py @@ -22,6 +22,7 @@ if False: from typing import Any, Dict # NOQA from sphinx.application import Sphinx # NOQA from sphinx.environment import BuildEnvironment # NOQA + from sphinx.writers.html import HTMLTranslator # NOQA def html_visit_math(self, node): @@ -32,7 +33,7 @@ def html_visit_math(self, node): def html_visit_displaymath(self, node): - # type: (nodes.NodeVisitor, nodes.Node) -> None + # type: (HTMLTranslator, nodes.Node) -> None if node['nowrap']: self.body.append(self.starttag(node, 'div', CLASS='math notranslate nohighlight')) self.body.append(self.encode(node.astext())) diff --git a/sphinx/ext/mathjax.py b/sphinx/ext/mathjax.py index 21406c451..3786c8107 100644 --- a/sphinx/ext/mathjax.py +++ b/sphinx/ext/mathjax.py @@ -25,6 +25,7 @@ if False: from typing import Any, Dict # NOQA from sphinx.application import Sphinx # NOQA from sphinx.environment import BuildEnvironment # NOQA + from sphinx.writers.html import HTMLTranslator # NOQA def html_visit_math(self, node): @@ -37,7 +38,7 @@ def html_visit_math(self, node): def html_visit_displaymath(self, node): - # type: (nodes.NodeVisitor, nodes.Node) -> None + # type: (HTMLTranslator, nodes.Node) -> None self.body.append(self.starttag(node, 'div', CLASS='math notranslate nohighlight')) if node['nowrap']: self.body.append(self.encode(node.astext())) diff --git a/sphinx/util/math.py b/sphinx/util/math.py index b960613c0..58f8a17d0 100644 --- a/sphinx/util/math.py +++ b/sphinx/util/math.py @@ -13,11 +13,11 @@ if False: # For type annotation from docutils import nodes # NOQA - from docutils.writers.html4css1 import Writer # NOQA + from sphinx.builders.html import HTMLTranslator # NOQA def get_node_equation_number(writer, node): - # type: (Writer, nodes.Node) -> unicode + # type: (HTMLTranslator, nodes.Node) -> unicode if writer.builder.config.math_numfig and writer.builder.config.numfig: figtype = 'displaymath' if writer.builder.name == 'singlehtml': @@ -27,11 +27,9 @@ def get_node_equation_number(writer, node): id = node['ids'][0] number = writer.builder.fignumbers.get(key, {}).get(id, ()) - number = '.'.join(map(str, number)) + return '.'.join(map(str, number)) else: - number = node['number'] - - return number + return node['number'] def wrap_displaymath(text, label, numbering):