Not able to add node sockets to an existing node using python scripting I am trying to add a new input NodeSocket to an existing node using the below code:

tree = bpy.context.scene.node_tree
tree.nodes['File Output'].inputs.new('RGBA', 'Image')
tree.nodes['File Output'].update()


Below are the nodes that I have created for my blend file.



As shown in the above image, the "File Output" node has 5 input sockets. The above code should add a 6th one, however it is not adding. Am I missing something here?
Found out from here that instead of adding sockets to these node using the node.inputs collection, the node.file_slots or node.layer_slots collections should be used. Both of them work, they just provide slightly different properties for use with simple files or multi-layer EXR.