Skip to content

Commit

Permalink
preserve order upon simplification of OrdAttMap
Browse files Browse the repository at this point in the history
  • Loading branch information
vreuter committed May 10, 2019
1 parent 97737bb commit 5428570
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions attmap/_att_map_like.py
Expand Up @@ -176,10 +176,10 @@ def _excl_from_repr(self, k, cls):
"""
return False

@staticmethod
def _new_empty_basic_map():
@abc.abstractmethod
def _new_empty_basic_map(self):
""" Return the empty collection builder for Mapping type simplification. """
return dict()
pass

def _data_for_repr(self):
return filter(lambda kv: not self._excl_from_repr(kv[0], self.__class__),
Expand Down
4 changes: 4 additions & 0 deletions attmap/attmap.py
Expand Up @@ -53,6 +53,10 @@ def __getattr__(self, item, default=None):
# Throw up our hands in despair and resort to exception behavior.
raise AttributeError(item)

def _new_empty_basic_map(self):
""" Return the empty collection builder for Mapping type simplification. """
return dict()

@property
def _transformations(self):
"""
Expand Down
3 changes: 3 additions & 0 deletions attmap/ordattmap.py
Expand Up @@ -15,3 +15,6 @@ class OrdAttMap(AttMap, OrderedDict):
def __init__(self, entries=None):
super(OrderedDict, self).__init__()
super(AttMap, self).__init__(entries)

def _new_empty_basic_map(self):
return OrderedDict()

0 comments on commit 5428570

Please sign in to comment.