[core] Refactor nodeFactory function

Rewrite `nodeFactory` to reduce cognitive complexity,
while preserving the current behavior.
This commit is contained in:
Yann Lanthony 2025-02-06 16:46:04 +01:00
parent 75db9dc16c
commit c883c53397
3 changed files with 175 additions and 93 deletions

View file

@ -432,11 +432,12 @@ class UpgradeNodeCommand(GraphCommand):
def undoImpl(self):
# delete upgraded node
expectedUid = self.graph.node(self.nodeName)._uid
self.graph.removeNode(self.nodeName)
# recreate compatibility node
with GraphModification(self.graph):
# We come back from an upgrade, so we enforce uidConflict=True as there was a uid conflict before
node = nodeFactory(self.nodeDict, name=self.nodeName, uidConflict=True)
node = nodeFactory(self.nodeDict, name=self.nodeName, expectedUid=expectedUid)
self.graph.addNode(node, self.nodeName)
# recreate out edges
for dstAttr, srcAttr in self.outEdges.items():