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

Implement __eq__ for FeatureFlag #349

Merged
merged 2 commits into from
Jul 25, 2023
Merged

Implement __eq__ for FeatureFlag #349

merged 2 commits into from
Jul 25, 2023

Conversation

imjoehaines
Copy link
Contributor

Goal

Implement __eq__ for FeatureFlag so that they are compared by name & variant, rather than by object identity

This is primarily to make the unit tests easier to write but could also be helpful in callbacks for the same reasons — it makes comparing feature flags easier:

flag1 = FeatureFlag('a', '1')
flag2 = FeatureFlag('b', '2')

# without this change:
flags_are_equal = flag1.name == flag2.name and flag1.variant == flag2.variant

# with this change:
flags_are_equal = flag1 == flag2

@imjoehaines imjoehaines requested a review from Cawllec July 24, 2023 09:17
@imjoehaines imjoehaines merged commit 9754c5b into next Jul 25, 2023
20 checks passed
@imjoehaines imjoehaines deleted the feature-flags-eq branch July 25, 2023 07:33
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

Successfully merging this pull request may close these issues.

2 participants