calliope icon indicating copy to clipboard operation
calliope copied to clipboard

AttrDict fails when uniting regular dicts

Open irm-codebase opened this issue 1 year ago • 4 comments

What happened?

At the moment, AttrDict will fail to execute union if the merged object is a regular dictionary. This is despite the docstrings suggesting that this should be possible.

The cause is that we directly call other.keys_nested(), which is AttrDict exclusive. The solution is an additional check istype(other, AttrDict), and converting if False.

Which operating systems have you used?

  • [ ] macOS
  • [ ] Windows
  • [X] Linux

Version

v0.7

Relevant log output

No response

irm-codebase avatar Jul 17 '24 18:07 irm-codebase

We desperately want to move away from AttrDict (see #366) rather than constantly patching it. However, we haven't found an alternative that fits our needs.

brynpickering avatar Jul 19 '24 10:07 brynpickering

@brynpickering I was looking at alternatives, and I found dotmap: https://github.com/drgrib/dotmap/tree/master

The only thing its missing is the "disallow overrides" feature we have, although I feel like we are always turning that off... It has one disadvantage, though: it uses OrderedDict instead of just dict, which is slightly slower.

irm-codebase avatar Jul 19 '24 10:07 irm-codebase

Hmm yeah, the others I found also have only one downside each, so it's three options each with one problem making them unsuitable as drop-in replacements 😄

brynpickering avatar Jul 19 '24 10:07 brynpickering

I'll try to come up with a nice working alternative later, so let's keep this issue open for now.

(subclass of Box with union_no_override or something)

irm-codebase avatar Jul 19 '24 11:07 irm-codebase