Possible move of comparison to a separate function inside set
- Dominant language
- Python
- Stars
- 653
- Forks
- 217
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 2
Description
``` python
try:
silent = bool(old_value == new_value)
except:
# if there is an error in comparing, default to notify
silent = False
```
When `==` doesn't work (think `np.array` or `pd.DataFrame`), this is equivalent to failing silently in some sense. We should move this section to a separate compare function that can be overload by a `TraitType` so the entire logic of `set` doesn't need to be copied.
Contributor guide
Research direction
Start by locating the set implementation and the TraitType classes that participate in assignment. Extract the equality comparison into an overridable comparison function so TraitType implementations can handle values such as numpy arrays or pandas dataframes without duplicating set logic; done means existing notification behavior remains intact and specialized comparisons can be supplied.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100