Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for marshalling dict-like objects. #61

Merged
merged 1 commit into from
Feb 24, 2016

Conversation

obmarg
Copy link
Contributor

@obmarg obmarg commented Nov 26, 2015

The is_dict_like function in schema.py was just checking if the
object's type was a dict. This causes it to treat any dict subclass as
a model, which fails because dict subclasses are not models.

Updating to check if the item is an instance of collections.Mapping
(or collections.abc.Mapping on python 3) fixes this.

The `is_dict_like` function in `schema.py` was just checking if the
object's type was a dict.  This causes it to treat any dict subclass as
a model, which fails because dict subclasses are not models.

Updating to check if the item is an instance of `collections.Mapping`
(or `collections.abc.Mapping` on python 3) fixes this.
try:
from collections import Mapping
except ImportError:
from collections.abc import Mapping
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw, I doubt this ImportError will ever be hit (even in python3):

# head -n 8 /usr/lib/python3.5/collections/__init__.py
__all__ = ['deque', 'defaultdict', 'namedtuple', 'UserDict', 'UserList',
            'UserString', 'Counter', 'OrderedDict', 'ChainMap']

# For backwards compatibility, continue to make the collections ABCs
# available through the collections module.
from _collections_abc import *
import _collections_abc
__all__ += _collections_abc.__all__

@analogue
Copy link
Contributor

Will fix the extraneous import logic post-merge.

@analogue
Copy link
Contributor

@obmarg Thanks! 👍

analogue added a commit that referenced this pull request Feb 24, 2016
Add support for marshalling dict-like objects.
@analogue analogue merged commit 628b164 into Yelp:master Feb 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants