Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label comparison not working #187

Closed
juanchristian opened this issue Feb 20, 2017 · 4 comments
Closed

Label comparison not working #187

juanchristian opened this issue Feb 20, 2017 · 4 comments

Comments

@juanchristian
Copy link
Contributor

juanchristian commented Feb 20, 2017

I created a dict that consists of all my board labels, key being the label name and value being the Label object, as follows: {'TO DO': <Label TO DO>, 'DONE': <Label DONE>, 'VERIFIED': <Label VERIFIED>, 'APPROVED': <Label APPROVED>, 'DOING': <Label DOING>}

I'm working on a personal script to automate some Trello related jobs, one of them is keeping card labels up-to-date based on some rules and external sources. Let's say I have the card LoremIpsum with only one label, <Label TO DO>.

If I try to do this:

board_labels = {label.name: label for label in card.board.get_labels()}  # board_labels: {'TO DO': <Label TO DO>, 'DONE': <Label DONE>, 'VERIFIED': <Label VERIFIED>, 'APPROVED': <Label APPROVED>, 'DOING': <Label DOING>}
print(card.labels)  # print: [<Label TO DO>]
print(board_labels["TO DO"] in card.labels)  # print: False

It should print True, but instead it print False, why?

@juanchristian juanchristian changed the title Label Comparison using "not in" not working Label Comparison using not working Feb 20, 2017
@juanchristian juanchristian changed the title Label Comparison using not working Label comparison not working Feb 20, 2017
@juanchristian
Copy link
Contributor Author

Any update? 6 days old ticket :(

@juanchristian
Copy link
Contributor Author

juanchristian commented Feb 25, 2017

So, just checked inside label.py and it's simply because there isn't an override of __eq__, something like:

def __eq__(self, other):
	return self.id == other.id if isinstance(other, self) else False

Would do the trick :)

PS: The same could and should be done for card, board, etc, as comparing objects like these is pretty common :)

@sgaynetdinov
Copy link
Contributor

sgaynetdinov commented Apr 13, 2017

Hello, i'm create pull request (#193)
which closes the problem with Label

PS: The same could and should be done for card, board, etc, as comparing objects like these is pretty common :)

You can create dressed tasks for these questions?

@juanchristian
Copy link
Contributor Author

@sgaynetdinov I'll try to do that on my spare time.

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

No branches or pull requests

2 participants