Skip to content

Add the method to check equality in Block Kit model classes #1131

@uroboro

Description

@uroboro

Reproducible in:

The Slack SDK version

All versions

Steps to reproduce:

from slack_sdk.models.blocks import DividerBlock
DividerBlock() == DividerBlock()

It happens with any pair of equivalent blocks.

Expected result:

True

Actual result:

False

Suggested solution

Implementing __eq__ in JsonObject.

class JsonObject(BaseObject, metaclass=ABCMeta):
    ...
    def __eq__(self, other: Any) -> bool:
        if not isinstance(other, JsonObject):
            return NotImplemented
        return self.to_dict() == other.to_dict()

This would allow testing user functions that accept and/or return Slack SDK models.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions