Repository navigation
fix config equality check not considering "enabled" - #2940
Conversation
There was a problem hiding this comment.
This should work.
But we may want to rename _all_settings to something like _custom_config_keys or _custom_plugin_settings now, just for clarity.
But there is one strange thing that I don't quite understand at the moment. It looks like before I made the change in a3bd1df, the "enabled" field was also not checked for equality. Maybe there was another related change in that commit that made starting/stopping configs on "enabled" toggle work before and after, but I don't see it right now.
Because EDIT: Oh, you said before your change. Yeah... |
| def __eq__(self, other: object) -> bool: | ||
| if not isinstance(other, ClientConfig) or self._all_settings != other._all_settings: | ||
| return False | ||
| for k, v in self.__dict__.items(): | ||
| return ( | ||
| isinstance(other, ClientConfig) | ||
| and self._custom_config_keys == other._custom_config_keys | ||
| # "settings" are not considered when checking for equality | ||
| if not k.startswith("_") and k != 'settings' and v != getattr(other, k): | ||
| return False | ||
| return True | ||
| and all(k == 'settings' or getattr(self, k) == getattr(other, k) for k in self.CONFIG_KEYS) | ||
| ) |
There was a problem hiding this comment.
Perhaps this way of writing reads better:
def __eq__(self, other: object) -> bool:
return (
isinstance(other, ClientConfig)
and self._custom_config_keys == other._custom_config_keys
# "settings" are not considered when checking for equality
and all(k == 'settings' or getattr(self, k) == getattr(other, k) for k in self.CONFIG_KEYS)
)There was a problem hiding this comment.
Okay for me.
You should probably make a hotfix release with this fix (or re-tag before Package Control sees the release).
There was a problem hiding this comment.

Fixes #2936 (comment)