plotly / dash

Data Apps & Dashboards for Python. No JavaScript Required.
https://plotly.com/dash
MIT License
21.19k stars 2.04k forks source link

Hash in DashDependency does not take class name into account #1658

Open hhoeflin opened 3 years ago

hhoeflin commented 3 years ago

In

https://github.com/plotly/dash/blob/e727dd7e37d20147f6eefbdd35bd12319a026b27/dash/dependencies.py#L27

the hash is implemented as

def __hash__(self):
    hash(str(self))

where

def __str__(self):
    return "{}.{}".format(self.component_id_str(), self.component_property)

def __repr__(self):
    return "<{} `{}`>".format(self.__class__.__name__, self)

so that an Input and State with the same id would yield the same hash-value.

I plan to insert Input and State objects into a dict, and this could cause issues.

alexcjohnson commented 3 years ago

Good catch @hhoeflin - let's change that to hash(repr(self))