Skip to content

Commit

Permalink
Future proof xml parsing in graphml. (networkx#7360)
Browse files Browse the repository at this point in the history
As of Python 3.12, the lxml tree parser raises a warning about
evaluating truthiness of elements directly, instead recommending
an is not None or len() test.
  • Loading branch information
rossbar committed Mar 20, 2024
1 parent e71bd8a commit bc94afe
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion networkx/readwrite/graphml.py
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ def decode_data_elements(self, graphml_keys, obj_xml):
node_label = None
# set GenericNode's configuration as shape type
gn = data_element.find(f"{{{self.NS_Y}}}GenericNode")
if gn:
if gn is not None:
data["shape_type"] = gn.get("configuration")
for node_type in ["GenericNode", "ShapeNode", "SVGNode", "ImageNode"]:
pref = f"{{{self.NS_Y}}}{node_type}/{{{self.NS_Y}}}"
Expand Down

0 comments on commit bc94afe

Please sign in to comment.