diff options
-rw-r--r-- | pyproject.toml | 3 | ||||
-rw-r--r-- | sphinx/util/nodes.py | 8 |
2 files changed, 5 insertions, 6 deletions
diff --git a/pyproject.toml b/pyproject.toml index 70b44edaf..78c8bec05 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -251,11 +251,10 @@ module = [ "sphinx.util.cfamily", "sphinx.util.docfields", "sphinx.util.docutils", - "sphinx.util.nodes", "sphinx.util.typing", "sphinx.writers.latex", "sphinx.writers.text", - "sphinx.writers.xml" + "sphinx.writers.xml", ] strict_optional = false diff --git a/sphinx/util/nodes.py b/sphinx/util/nodes.py index 201b547d9..884965b93 100644 --- a/sphinx/util/nodes.py +++ b/sphinx/util/nodes.py @@ -264,18 +264,18 @@ def extract_messages(doctree: Element) -> Iterable[tuple[Element, str]]: yield node, msg -def get_node_source(node: Element) -> str | None: +def get_node_source(node: Element) -> str: for pnode in traverse_parent(node): if pnode.source: return pnode.source - return None + raise ValueError("node source not found") -def get_node_line(node: Element) -> int | None: +def get_node_line(node: Element) -> int: for pnode in traverse_parent(node): if pnode.line: return pnode.line - return None + raise ValueError("node line not found") def traverse_parent(node: Element, cls: Any = None) -> Iterable[Element]: |