feat: add support for nullable parameters in API calls in python#1098
Closed
ChiragAgg5k wants to merge 2 commits intomasterfrom
Closed
feat: add support for nullable parameters in API calls in python#1098ChiragAgg5k wants to merge 2 commits intomasterfrom
ChiragAgg5k wants to merge 2 commits intomasterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR enhances the Python SDK’s request builder so that parameters marked as nullable in the API schema aren’t dropped when they’re explicitly set to None.
- Added a
nullable_paramsargument toClient.calland updated the filtering logic - Updated the low-level request template to pass nullable parameters through
- Populated
nullable_paramsin the parameter-gathering template
Comments suppressed due to low confidence (3)
templates/python/package/client.py.twig:52
- The new
nullable_paramsargument should be documented (e.g., in a docstring or comment) to explain that it is a list of parameter names that should not have theirNonevalues filtered out.
def call(self, method, path='', headers=None, params=None, response_type='json', nullable_params=None):
templates/python/base/requests/api.twig:8
- Passing
nullable_paramsas a positional argument can shift the meaning of subsequent positional parameters; consider usingnullable_params=nullable_paramsas a named argument to avoid breaking callers if the signature changes.
}, api_params, nullable_params{% if method.type == 'webAuth' %}, response_type='location'{% endif %})
templates/python/package/client.py.twig:63
- We should add or update unit tests to cover the new behavior: verify that parameters listed in
nullable_paramsremain in the request payload even when their value isNone.
params = {k: v for k, v in params.items() if v is not None or k in nullable_params}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
currently python sdk filters out all
Nonevalues from api requests. but attributes likedefaultcan be nullable, and hence should not be filtered outTest Plan
Related PRs and Issues
Have you read the Contributing Guidelines on issues?
yes.