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

Add pop method to web3.datastructures.AttributeDict #3326

Closed
antazoey opened this issue Apr 2, 2024 · 1 comment
Closed

Add pop method to web3.datastructures.AttributeDict #3326

antazoey opened this issue Apr 2, 2024 · 1 comment

Comments

@antazoey
Copy link
Contributor

antazoey commented Apr 2, 2024

What feature should we add?

Right now, this confusingly fails:

data = eth_tester_provider.web3.eth.get_block("latest")
size = data.pop("size", None)

AttributeError: 'AttributeDict' object has no attribute 'pop'

My workaround is this:

data = {**eth_tester_provider.web3.eth.get_block("latest")}
size = data.pop("size", None)

My feature request is to add the pop method to AttributeDict so it works the same as regular dicts in that regard.

@pacrob
Copy link
Contributor

pacrob commented Apr 9, 2024

AttributeDict was created with the idea that it should be immutable. It seems like if you want to pop things from it, copying then popping would be the way to go.

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