Closed hbierlee closed 1 year ago
Hi! I'm trying to fix an issue where ruamel (strangely) can't serialize range objects which are part of the MiniZinc model's output:
ruamel
|| def represent_undefined(self, data: Any) -> None: || > raise RepresenterError(f'cannot represent an object: {data!s}') || E ruamel.yaml.representer.RepresenterError: cannot represent an object: range(1, 5)
I don't know why a python range is not a default registered class for ruamel, but adding yaml.register_class(range) also doesn't work:
yaml.register_class(range)
|| self = <ruamel.yaml.representer.SafeRepresenter object at 0x7f529a523ee0> || tag = '!range', data = range(1, 5), cls = <class 'range'>, flow_style = None || || def represent_yaml_object( || self, tag: Any, data: Any, cls: Any, flow_style: Any = None || ) -> MappingNode: || if hasattr(data, '__getstate__'): || state = data.__getstate__() || else: || > state = data.__dict__.copy() || E AttributeError: 'range' object has no attribute '__dict__'. Did you mean: '__dir__'?
Any ideas on how to fix it so ranges are serialized normally?
Should be fixed by https://github.com/MiniZinc/minizinc-python/pull/90
Hi! I'm trying to fix an issue where
ruamel
(strangely) can't serialize range objects which are part of the MiniZinc model's output:I don't know why a python range is not a default registered class for ruamel, but adding
yaml.register_class(range)
also doesn't work:Any ideas on how to fix it so ranges are serialized normally?