Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion attmap/attmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,18 @@ def _metamorph_maplike(self, m: Mapping) -> "AttMap":
raise TypeError(
"Cannot integrate a non-Mapping: {}\nType: {}".format(m, type(m))
)
return self._lower_type_bound(m.items())
# Merge any extra instance attributes from non-builtin Mappings
# so they aren't lost during type conversion.
extra = []
try:
extra = [
(k, v)
for k, v in vars(m).items()
if not k.startswith("_") and k not in m
]
except TypeError:
pass
return self._lower_type_bound(list(m.items()) + extra)

def _new_empty_basic_map(self) -> dict:
"""Return the empty collection builder for Mapping type simplification."""
Expand Down