-
Notifications
You must be signed in to change notification settings - Fork 27
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #117 +/- ##
=======================================
Coverage 98.77% 98.77%
=======================================
Files 18 18
Lines 732 737 +5
=======================================
+ Hits 723 728 +5
Misses 9 9
Continue to review full report at Codecov.
|
There was a problem hiding this 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.
ibm_cloud_sdk_core/base_service.py
Outdated
# 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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.)?
Sure! |
## [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))
🎉 This PR is included in version 3.10.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This PR introduces a minor change/improvement: removal of some reserved keys from the
kwargs
of the base services' send function.