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

Fix NestedField Type hint for Lambda Schema types #2164

Merged
merged 2 commits into from
Aug 15, 2023

Conversation

somethingnew2-0
Copy link
Contributor

Providing a lambda with a returning callable type is handled by Marshmallow (such as below), but not allowed by the type-hinting. Fix that

class PrimarySchema(Schema):
    other = fields.Nested(lambda: OtherSchema)

@lafrech
Copy link
Member

lafrech commented Aug 11, 2023

Thanks.

Would you like to add yourself to AUTHORS file?

I'm wondering if we could be more specific than type. Could we enforce that it is just not any type but only schema types? Like, by specifying SchemaMeta rather than type? This question applies to the whole codebase, so we may merge anyway, but I'd be interested to gather thoughts about this.

@somethingnew2-0
Copy link
Contributor Author

@lafrech added myself to AUTHORS

SchemaMeta does appear to work in my codebase to be more specific than type. But I agree that it should probably be updated everywhere in marshmallow where type was used such as on line 536 of the same method https://github.com/marshmallow-code/marshmallow/pull/2164/files#diff-0cddc4aac0e4e16946830a5807c264d65b7f14a2a1b1cb23b03028a36df3681aR536

@lafrech
Copy link
Member

lafrech commented Aug 15, 2023

Yes, exactly. Thanks for the feedback. This can be done in another (welcome) PR.

@lafrech lafrech merged commit 9fa323c into marshmallow-code:dev Aug 15, 2023
6 checks passed
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.

2 participants