Skip to content

v3.0.0

Latest
Compare
Choose a tag to compare
@BALOGHBence BALOGHBence released this 06 Dec 18:56
· 5 commits to main since this release
7a9cdf7

What's Changed

Full Changelog: v2.0.1...v3.0.0

Added

  • Added type checks for the magic methods __getitem__, __setitem__ and __delitem__.
  • Added a custom exception type DeepDictLockedError for when a locked dictionary is about to be modified.
  • Added new special methods __before_join_parent__, __after_join_parent__, __before_leave_parent__ and __after_leave_parent__ to replace the hooks __leave_parent__ and __join_parent__.

Changed

  • The behaviour when assigning a None value to a key has been changed:

    from sigmaepsilon.deepdict import DeepDict
    dd = DeepDict()
    dd["key"] = "value"
    dd["key"] = None

    Previously, this would delete the key from the dictionary, which was inconsistent with the behavior of the built-in dict class. Starting from this version, the last line will only set the value to None without deleting the key. To delete the key, you should now use:

    del dd["key"]
  • Customizing the behaviour upon deleting a DeepDict from its parent and adding a child DeepDict has been changed, see the notes at the 'Deprecated' section.

  • Changed the locking behaviour to cover for all scenarios that would modify the layout of a dictionary. The previous implementation only covered creating new keys, but it didn't protect agains deletions.

Deprecated

The use of the hooks __leave_parent__ and __join_parent__ is deprecated. They are replaced with __before_join_parent__, __after_join_parent__, __before_leave_parent__ and __after_leave_parent__, which provides more fine grained control. See the documentation for more details.

Refactored

Refactored the implementations of magic methods __setitem__, __getitem__ and __delitem__ for better clarity and improved code quality.