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

refactor: make Reason enum values instances of str #142

Merged
merged 1 commit into from
Jul 12, 2023

Conversation

federicobond
Copy link
Member

This PR

Is a refinement on #126. In particular, it makes Reason values also instances of str, and thus directly comparable without having to access the .value property, and without having to define custom getters and setters in dataclasses.

The motivation for this was to fix a no-redef issue reported by mypy in the FlagEvaluationDetails definition:

open_feature/flag_evaluation/flag_evaluation_details.py:19: error: Name "reason" already defined on line 15  [no-redef]

StrEnum is available since Python 3.11 so it requires a minimal backport for earlier Python versions.

@federicobond federicobond force-pushed the strenum branch 3 times, most recently from bf8ebec to 5be2ae4 Compare July 11, 2023 14:09
Signed-off-by: Federico Bond <federicobond@gmail.com>
@codecov
Copy link

codecov bot commented Jul 11, 2023

Codecov Report

Merging #142 (1e9e37f) into main (695da28) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #142   +/-   ##
=======================================
  Coverage   93.26%   93.26%           
=======================================
  Files          21       22    +1     
  Lines         386      386           
=======================================
  Hits          360      360           
  Misses         26       26           
Flag Coverage Δ
unittests 93.26% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...feature/flag_evaluation/flag_evaluation_details.py 100.00% <ø> (ø)
open_feature/_backports/strenum.py 100.00% <100.00%> (ø)
open_feature/flag_evaluation/reason.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

Copy link
Collaborator

@hlipsig hlipsig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have any concerns here. This is a good change.

@beeme1mr beeme1mr merged commit 633deff into open-feature:main Jul 12, 2023
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.

3 participants