plotly / plotly/dash

Hash in DashDependency does not take class name into account

Open
#1,658 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
24.4k
Forks
2.3k
Avg merge
2d 7h
Merged PRs (30d)
13

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in dash/dependencies.py around line 27 and inspect how DashDependency, Input, and State define hash, str, and repr. Compare the dictionary behavior for Input and State instances with the same id and property, then add or update regression coverage so the class distinction is handled as intended.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.