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: use if clauses in list comprehensions to make code more pythonic #215

Merged
merged 2 commits into from
Oct 19, 2023

Conversation

federicobond
Copy link
Member

This PR

Rewrites the _execute_hooks* functions to be more pythonic. This improves readability and makes the code faster since it avoids the creation of intermediate structures.

I also removed the null guards since the functions are typed as receiving lists always.

…honic

Signed-off-by: Federico Bond <federicobond@gmail.com>
@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Merging #215 (f607b9a) into main (84af1ae) will increase coverage by 0.28%.
Report is 1 commits behind head on main.
The diff coverage is 87.50%.

@@            Coverage Diff             @@
##             main     #215      +/-   ##
==========================================
+ Coverage   93.34%   93.63%   +0.28%     
==========================================
  Files          16       16              
  Lines         451      440      -11     
==========================================
- Hits          421      412       -9     
+ Misses         30       28       -2     
Flag Coverage Δ
unittests 93.63% <87.50%> (+0.28%) ⬆️

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

Files Coverage Δ
openfeature/evaluation_context.py 91.66% <100.00%> (+0.75%) ⬆️
openfeature/hook/hook_support.py 90.32% <100.00%> (+3.83%) ⬆️
openfeature/hook/__init__.py 83.33% <50.00%> (-2.78%) ⬇️

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

Copy link
Member

@beeme1mr beeme1mr left a comment

Choose a reason for hiding this comment

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

Honestly, I'm not entirely sure what's happening in this change 😅. Perhaps someone with some more Python experience can chime in.

@justinabrahms @tcarrio @jamescarr

Copy link
Member

@beeme1mr beeme1mr left a comment

Choose a reason for hiding this comment

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

The tests pass and this is just an internal refactor.

@federicobond federicobond merged commit 64f57fd into open-feature:main Oct 19, 2023
8 of 9 checks passed
@federicobond federicobond deleted the refactor-execute-hooks branch October 19, 2023 20:43
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