From bc94afe5d4a20777be1be78aa654c1f4233471e9 Mon Sep 17 00:00:00 2001 From: Ross Barnowski Date: Tue, 19 Mar 2024 18:22:52 -0700 Subject: [PATCH] Future proof xml parsing in graphml. (#7360) 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. --- networkx/readwrite/graphml.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/networkx/readwrite/graphml.py b/networkx/readwrite/graphml.py index 7d4fd7a6673..0b05e03a3b4 100644 --- a/networkx/readwrite/graphml.py +++ b/networkx/readwrite/graphml.py @@ -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}}}"