Add the method to check equality in Block Kit model classes
See original GitHub issueReproducible 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.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Reference: Block elements - Slack API
A comprehensive breakdown of elements that add images or interactivity to blocks.
Read more >How to compare two objects (testing for equality) in C#
It's common to compare two objects in C# for equality, such as detecting changes for a save operation. Let's take a closer look...
Read more >How to Compare Object Instances in your Unit Tests Quickly ...
When unit testing, you may need to compare attribute equality instead of the default reference equality of two object instances. It might not...
Read more >How to Compare Two Objects in Java - Javatpoint
The equals() method of the Object class compare the equality of two objects. The two objects will be equal if they share the...
Read more >Java equals() and hashCode() - DigitalOcean
Let's see what happens when we rely on default implementation of equals() and hashCode() methods and use a custom class as HashMap key....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @kokko-san, how are you doing?
Are you going to work on this shortly? If you don’t have the bandwidth to work on this in a few days, can I start working on this this week? All the other task items for the next release except this one are ready for release, and we are aiming to ship a new version within a few days.
Hi @kokko-san, thanks for your interest!
As for the change fixing this issue, all you need to do is to verify if all the unit tests pass. Also, we would like to have new test patterns to make sure if the change works as expected. For local development,
./scripts/run_unit_tests.sh (test file path)
may be handier.If you have time to complete the work within a few weeks (ideally within 1 to 2 weeks), we are happy to merge your contribution!