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

in update_in(), option to disable upsert #515

Open
fenom opened this issue May 6, 2021 · 1 comment
Open

in update_in(), option to disable upsert #515

fenom opened this issue May 6, 2021 · 1 comment

Comments

@fenom
Copy link

fenom commented May 6, 2021

I'm doing an update that is completely meaningless when the key doesn't already exist. I don't even want to use a default value. I just want to leave the key nonexistent. I know I can first see if get_in() is not None, but an option to disable upsert seems too natural to not have in an update function.

@groutr
Copy link
Contributor

groutr commented Jun 7, 2021

@fenom I agree. The correct place to disable upserts is by subclassing dict and replacing its update method to disable upserts. Then you would pass your new subclass using the factory=MySubclass keyword argument. dicttoolz.update_in essentially delegates to the update method of the mapping container.

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

No branches or pull requests

2 participants