bugsnag / bugsnag-python

Official BugSnag error monitoring and error reporting for django, flask, tornado and other python apps.
https://docs.bugsnag.com/platforms/python/
MIT License
84 stars 42 forks source link

Implement __eq__ for FeatureFlag #349

Closed imjoehaines closed 1 year ago

imjoehaines commented 1 year ago

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