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

BUG: Rules with the same name result in KeyError when both are added to a Rule_Collection #30

Open
HenryAsa opened this issue Apr 25, 2023 · 0 comments
Assignees
Labels
Bug Something isn't working

Comments

@HenryAsa
Copy link
Owner

Describe the issue:

Use the id() function to define the key values of a Rule object in a Rule_Collection rather than a Rule's name. id(Rule) returns a unique value (integer) for each object, so no two unique Rules will have the same id() value.
However, two rules may have the same name, so even if the rules are different (have different attributes and serve different purposes), if they have the same name (which is also possible because they may both be unnamed and just use the default name), then there will be an error in the Rule_Collection.

Reproduce the code example:

from gmail_rules.rules import Rule
from gmail_rules.actions import Rule_Collection

rule_1 = Rule(rule_name="Mango")
rule_2 = Rule(rule_name="Mango")

rule_collection_1 = Rule_Collection()
rule_collection_1.add_rule(rule_1)
rule_collection_2.add_rule(rule_2)

Error message:

KeyError: 'Mango is already in the collection of rules.  Use update_rule() to change the value of this rule'

Screenshots

No response

OS

Mac

@HenryAsa HenryAsa added the Bug Something isn't working label Apr 25, 2023
@HenryAsa HenryAsa self-assigned this Apr 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant