-
-
Notifications
You must be signed in to change notification settings - Fork 620
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_default
reusing property instance between loaded instances
#2156
Comments
This is the dreaded Python "mutable default argument" pitfall. Search here or on the Internet. |
@lafrech thanks for quick answer! I know that Python have such odd behaviour, but for serialisation use case can't library under the hood prepare I don't see at first glance any use cases when it is desired so maybe it would be good to have reasonable default behaviour? |
Up till now our stance has been "pass a callable". Most of the time, it's gonna be This can always be reconsidered, though. But is it worth it? |
Hi
I've defined following schema for my HTTP request (use flask as http server)
When testing application locally I've noticed super strange behaviour: for subsequent HTTP requests when
variables
is not provided in request payload I sometimes see that it is not empty dict.It looks that
load_default
re-use instance so when during internal processing/some request provide value for it, requests without this value won't have empty dict but contain value from different request.Is it a way to make sure that default values will always be as defined (not share mutable instance)?
The text was updated successfully, but these errors were encountered: