Skip to content

fix config equality check not considering "enabled" - #2940

Merged
rchl merged 4 commits into
mainfrom
fix/config-eq
May 29, 2026
Merged

rchl merged 4 commits into
mainfrom
fix/config-eq

Conversation

@rchl

@rchl rchl commented May 29, 2026

Copy link
Copy Markdown
Member

@jwortmann jwortmann left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@rchl

rchl commented May 29, 2026 •

Copy link
Copy Markdown
Member Author

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 enabled was in _all_settings, which was checked for equality?

EDIT: Oh, you said before your change. Yeah...

Comment thread plugin/core/types.py
Comment on lines 1208 to +1214
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)
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
        )

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay for me.

You should probably make a hotfix release with this fix (or re-tag before Package Control sees the release).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jwortmann

Copy link
Copy Markdown
Member

Because enabled was in _all_settings, which was checked for equality?

Yes, but I mean before that commit. The _all_settings check was introduced in that commit, but before that _enabled would still be excluded from the equality check due to starting with _.

diff

@rchl
rchl merged commit 4970a4b into main May 29, 2026
8 checks passed
@rchl
rchl deleted the fix/config-eq branch May 29, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants