-
-
Notifications
You must be signed in to change notification settings - Fork 629
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
load accepts Sequence rather than Iterable (rejects generators) #2795
base: dev
Are you sure you want to change the base?
Conversation
ah, looks like this breaks handling of update: fixed |
this is ready for review. i thought this was a breaking change since it changes what we're accepting as valid input. but one could argue this is bugfix, since non-sequence inputs are silently failing to call schema validators. should this be backported to v3? |
Arguable. I don't really mind either way, but considering the move to v4 should be easy, I'm tempted to keep things as is in v3 and expect users to move fast to v4. Did we consider actually supporting generators? Is the rationale that this is costly to do in marshmallow so we prefer users unpack their generators themselves? |
we've never explicitly supported generators. the immediate rationale for this is that handling generators is currently broken but it fails silently (schema validators aren't called) |
Yes, I got that. Just wondering if we could solve this the other way by actually supporting the use case, and at what cost. This was investigated by @sirosen in #1898 (comment) and I don't think the downside he points to (post_load receives a list) is really an issue. |
gotcha. i'd rather avoid adding another runtime type-check, for the reason sirosen pointed out (pre_load wouldn't actually receive the "raw" input, which is pretty unintuitive) as well as the performance hit. |
addresses #1898
Caveat: for some reason, mypy doesn't error when passing a generator. it seems that generators are covariant with
Sequence
and are therefore equivalent for type-checking purposes. not sure if there is a better way to handle this.