mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #5719 from tk0miya/refactor_NodeMatcher
refactor NodeMatcher for mypy friendly
This commit is contained in:
commit
de37ad76a1
@ -68,18 +68,19 @@ class NodeMatcher:
|
|||||||
if self.classes and not isinstance(node, self.classes):
|
if self.classes and not isinstance(node, self.classes):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if self.attrs and isinstance(node, nodes.Text):
|
if self.attrs:
|
||||||
return False
|
if not isinstance(node, nodes.Element):
|
||||||
|
return False
|
||||||
|
|
||||||
for key, value in self.attrs.items():
|
for key, value in self.attrs.items():
|
||||||
if key not in node:
|
if key not in node:
|
||||||
return False
|
return False
|
||||||
elif value is Any:
|
elif value is Any:
|
||||||
continue
|
continue
|
||||||
elif node.get(key) != value:
|
elif node.get(key) != value:
|
||||||
return False
|
return False
|
||||||
else:
|
|
||||||
return True
|
return True
|
||||||
except Exception:
|
except Exception:
|
||||||
# for non-Element nodes
|
# for non-Element nodes
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user