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

Propagate strict overrides through nested models #318

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kstrauser
Copy link
Contributor

This allows model-instantion-type overrides of strictness settings so that use cases like this work:

    class Inner(Model):
        expected_key = StringType()

    class Outer(Model):
        """docstring"""
        inner = ModelType(Inner)

    doc = {
        'inner': {
            'expected_key': 'expected value',
            'rogue_key': 'unexpected value',
        },
    }

   print Outer(doc, strict=False).inner.expected_key

The default behavior of honoring the models' configured strictness is maintained, but explicitly setting strict=[value] overrides that behavior in expected ways.

@bintoro
Copy link
Member

bintoro commented Nov 24, 2015

#359 fixed the propagation issue, but it tentatively removed the ModelType.strict option since I wasn't sure if there's an actual use case for it or if it was introduced as a half-baked way to get some control over the strictness of embedded models (since the propagation didn't work).

If there is indeed a true need for ModelType.strict, then let's leave this PR open until those tests pass too.

@kstrauser
Copy link
Contributor Author

Yay! \o/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants