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

Warnings and errors for incompatible use of schema instance and many in fields.Nested #1983

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

mmulqueen
Copy link

Addresses the issue I've described in #1982. Behaviour should be unchanged, but more obvious.

Copy link
Member

@lafrech lafrech left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution and sorry about the delay.

I understand the issue. Yet I'm reluctant to add code just to warn about this specific case.

I left a few comments anyway. I might change my mind and accept the test at init. No strong opinion against it.

if self.many and not self.schema.many:
raise FieldConfigurationError(
'"many" may not be used in conjunction with an instance in a nested field.'
)
Copy link
Member

Choose a reason for hiding this comment

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

I'd remove this test. This should be coverered by the init warning you added above, right?

many = self.schema.many or self.many
if many and not utils.is_collection(value):
raise self.make_error("type", input=value, type=value.__class__.__name__)
# Check whether many on the nested field and the schema are in conflict.
Copy link
Member

Choose a reason for hiding this comment

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

I guess this comment was meant for the change above?

warnings.warn(
'Passing "many" is ignored if using an instance of a schema. Consider fields.List(fields.Nested(...)) instead.',
FieldConfigurationWarning,
)
Copy link
Member

Choose a reason for hiding this comment

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

I'd remove the suggestion.

@deckar01
Copy link
Member

#779 lists other unexpected edge cases like this. I would rather bite the bullet and deprecate many=True than go down the path of maintaining edge case warnings.

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