You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
a) Adjust the __hash__ function. Recursively look for mutable types like lists, etc. and temporary replace them before hashing.
This would likely also require changing __eq__ as two object can now have the same hash without being "equal".
def__init__(
self, dictionary: Dict[TKey, TValue], *args: Any, **kwargs: Any
) ->None:
# type ignored on 46/50 b/c dict() expects str index type not TKeyself.__dict__=dict(dictionary) # type: ignoreself.__dict__.update(dict(*args, **kwargs))
c) Handle it earlier, for instance when parsing response results.
d) Add a more restrictive TValue type (e.g. allow only hashable values). That seems a much larger change though as it likely affects many parts/sections of the code base.
The AttributeDict type is supposed to be immutable, this would suggest going with something like b).
I can prepare a PR, just need some directions on how you would like to have it solved.
The text was updated successfully, but these errors were encountered:
What was wrong?
Depending on the items,
AttributeDict
might not always be hashable.For example, log entries returned by
eth_getLogs()
can contain list objects (in this case 'topics'), which are not hashable.How can it be fixed?
a) Adjust the
__hash__
function. Recursively look for mutable types like lists, etc. and temporary replace them before hashing.This would likely also require changing
__eq__
as two object can now have the same hash without being "equal".source
b) Recursively replace mutable types (e.g. list -> tuple) when creating the AttributeDict object.
source
c) Handle it earlier, for instance when parsing response results.
d) Add a more restrictive
TValue
type (e.g. allow only hashable values). That seems a much larger change though as it likely affects many parts/sections of the code base.The
AttributeDict
type is supposed to be immutable, this would suggest going with something like b).I can prepare a PR, just need some directions on how you would like to have it solved.
The text was updated successfully, but these errors were encountered: