question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add the method to check equality in Block Kit model classes

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
seratchcommented, Nov 22, 2021

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.

1reaction
seratchcommented, Nov 15, 2021

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!

Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found