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

fix: remove reserved keywords from kwargs before passing it to requests #117

Merged
merged 4 commits into from
Jul 8, 2021

Conversation

pyrooka
Copy link
Member

@pyrooka pyrooka commented Jul 1, 2021

This PR introduces a minor change/improvement: removal of some reserved keys from the kwargs of the base services' send function.

@codecov
Copy link

codecov bot commented Jul 1, 2021

Codecov Report

Merging #117 (24dddc9) into main (6614a63) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #117   +/-   ##
=======================================
  Coverage   98.77%   98.77%           
=======================================
  Files          18       18           
  Lines         732      737    +5     
=======================================
+ Hits          723      728    +5     
  Misses          9        9           
Impacted Files Coverage Δ
ibm_cloud_sdk_core/base_service.py 97.39% <100.00%> (+0.06%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6614a63...24dddc9. Read the comment docs.

@pyrooka pyrooka requested a review from rmkeezer July 1, 2021 14:14
Copy link
Contributor

@rmkeezer rmkeezer left a comment

Choose a reason for hiding this comment

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

This approach seems fine for now. We will need to make sure the reserved_keys is correct in the future for any changes made to prepared_request.

The pylint is failing right now for what it seems to be an unrelated "no-member" error that I believe is a false positive. I assume this was added in a new version of pylint. I would go ahead and disable "no-member" in the pylintrc file and include it in this PR.

Also, I think it would be beneficial to add a unit test to sanity check this code, but I'll go ahead and approve this now.

# Remove the keys we set manually, don't let the user to overwrite these.
reserved_keys = ['method', 'url', 'headers', 'params', 'cookies']
for key in reserved_keys:
kwargs.pop(key, None)
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we want to just throw an error here or a message so the user knows their argument is being omitted.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think throwing an exception is not a good idea, since removing the headers will be quite common. I've added a warning log for now.

Copy link
Member

@padamstx padamstx left a comment

Choose a reason for hiding this comment

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

LGTM
After merging this PR, could you please do some additional testing with the platform-services python sdk (integration tests for a few services where you have the .env file, etc.)?

@pyrooka
Copy link
Member Author

pyrooka commented Jul 8, 2021

Sure!

@pyrooka pyrooka changed the title chore: remove reserved keywords from kwargs before passing down fix: remove reserved keywords from kwargs before passing down Jul 8, 2021
@pyrooka pyrooka changed the title fix: remove reserved keywords from kwargs before passing down fix: remove reserved keywords from kwargs before passing it to requests Jul 8, 2021
@pyrooka pyrooka merged commit 6191978 into main Jul 8, 2021
@pyrooka pyrooka deleted the kwargs-to-request branch July 8, 2021 15:13
ibm-devx-sdk pushed a commit that referenced this pull request Jul 8, 2021
## [3.10.1](v3.10.0...v3.10.1) (2021-07-08)

### Bug Fixes

* remove reserved keywords from kwargs before passing it to requests ([#117](#117)) ([6191978](6191978))
@ibm-devx-sdk
Copy link

🎉 This PR is included in version 3.10.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants