-
-
Notifications
You must be signed in to change notification settings - Fork 198
Create common interface for aio response classes #1328
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
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -204,15 +204,9 @@ async def _do_get_response(self, request, operation_model, context): | |
) | ||
parser = self._response_parser_factory.create_parser(protocol) | ||
|
||
if asyncio.iscoroutinefunction(parser.parse): | ||
parsed_response = await parser.parse( | ||
response_dict, operation_model.output_shape | ||
) | ||
else: | ||
parsed_response = parser.parse( | ||
response_dict, operation_model.output_shape | ||
) | ||
|
||
parsed_response = await parser.parse( | ||
response_dict, operation_model.output_shape | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. have we validated across all the parsers this is now true? Are there parsers that don't inherit from our baseclass? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i see everything parents to ResponseParser 👍🏼 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call! Upstream has a number of parsers that we have not patched:
The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could prepare a follow-up of #1312 to fully patch the parser class hierarchy. That would be a prerequisite for this PR, IMO. Any thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. #1329 makes sure that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I guess it would be, as long as we continue to allow for both sync and async variants of An alternative would be to simply keep the current implementation of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ya that's why I was waiting to do a review of this PR when I had some time, we need to thoroughly look at how these classes are used There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lets report back when one of us does that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about allowing sync There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sounds like a plan, would be safer |
||
parsed_response.update(customized_response_dict) | ||
|
||
if http_response.status_code >= 300: | ||
|
@@ -240,10 +234,7 @@ async def _add_modeled_error_fields( | |
if error_shape is None: | ||
return | ||
|
||
if asyncio.iscoroutinefunction(parser.parse): | ||
modeled_parse = await parser.parse(response_dict, error_shape) | ||
else: | ||
modeled_parse = parser.parse(response_dict, error_shape) | ||
modeled_parse = await parser.parse(response_dict, error_shape) | ||
# TODO: avoid naming conflicts with ResponseMetadata and Error | ||
parsed_response.update(modeled_parse) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,10 +150,5 @@ async def get_response(operation_model, http_response): | |
response_dict['body'] = await http_response.content | ||
|
||
parser = parsers.create_parser(protocol) | ||
if asyncio.iscoroutinefunction(parser.parse): | ||
parsed = await parser.parse( | ||
response_dict, operation_model.output_shape | ||
) | ||
else: | ||
parsed = parser.parse(response_dict, operation_model.output_shape) | ||
parsed = await parser.parse(response_dict, operation_model.output_shape) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apply deprecation pattern from |
||
return http_response, parsed |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That test was slightly refactored in the default branch. Please do a rebase or merge in new commits. |
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.
It's RST