Meanwhile, the docs state 'is expected to return a dictionary of string keys to string values representing the data payload' (same as for the graph_attrs parameter, for which the typing corresponds with the documentation).
On inserting a callable return a str datatype, this throws an error:
E TypeError: 'str' object cannot be converted to 'PyDict'
No error is thrown on return a dict
Our type annotations are added manually, so I think you just found a mismatch in the annotations! I might bundle the fix of this with #1242 for a 0.15.2 release. And of course it will be fixed by 0.16 for sure
Information
What is the current behavior?
Both
graph
anddigraph
_node_link_json
serializers show expectedcallable
output asstr
type. https://github.com/Qiskit/rustworkx/blob/553bff1823a30293c82fb811f4457b094700a728/rustworkx/rustworkx.pyi#L632-L647Meanwhile, the docs state 'is expected to return a dictionary of string keys to string values representing the data payload' (same as for the
graph_attrs
parameter, for which the typing corresponds with the documentation).From the rust function, the
dictionary
is also expected https://github.com/Qiskit/rustworkx/blob/553bff1823a30293c82fb811f4457b094700a728/src/json/node_link_data.rs#L125-L128On inserting a
callable
return astr
datatype, this throws an error:E TypeError: 'str' object cannot be converted to 'PyDict'
No error is thrown on return adict
What is the expected behavior?
Steps to reproduce the problem
Inserting
node_attrs=lambda x: 'a'
, which corresponds to theCallable[[_S], str] | None
type