diff --git a/ChangeLog.md b/ChangeLog.md index e2e097f6f53..ab90bc1e427 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -5,6 +5,8 @@ Modelerfour version: 4.13.351 **Bug Fixes** - Corrected generation of the item name of paging response when extracting data #648 +- Corrected return type typing annotation for operations that return an optional body #656 +- Fixed mypy issue by only setting the generated `deserialized` variable to None if the operation has an optional return typ #656 ### 2020-05-22 - 5.0.0-preview.8 Modelerfour version: 4.13.351 diff --git a/autorest/codegen/models/lro_operation.py b/autorest/codegen/models/lro_operation.py index 78be623f364..8983dd40cff 100644 --- a/autorest/codegen/models/lro_operation.py +++ b/autorest/codegen/models/lro_operation.py @@ -79,6 +79,11 @@ def set_lro_response_type(self) -> None: response_type = response_types[0] self.lro_response = response_type + @property + def has_optional_return_type(self) -> bool: + """An LROOperation will never have an optional return type, we will always return LROPoller[return type]""" + return False + def imports(self, code_model, async_mode: bool) -> FileImport: file_import = super().imports(code_model, async_mode) file_import.add_from_import("typing", "Union", ImportType.STDLIB, TypingSection.CONDITIONAL) diff --git a/autorest/codegen/models/operation.py b/autorest/codegen/models/operation.py index 10938b6b9b7..5ae527ea5c3 100644 --- a/autorest/codegen/models/operation.py +++ b/autorest/codegen/models/operation.py @@ -165,6 +165,30 @@ def is_stream_response(self) -> bool: """Is the response expected to be streamable, like a download.""" return any(response.is_stream_response for response in self.responses) + @property + def has_optional_return_type(self) -> bool: + """Has optional return type if there are multiple successful response types where some have + bodies and some are None + """ + + # successful status codes of responses that have bodies + status_codes_for_responses_with_bodies = [ + code for code in self.success_status_code + if isinstance(code, int) and self.get_response_from_status(code).has_body + ] + + successful_responses = [ + response for response in self.responses + if any(code in self.success_status_code for code in response.status_codes) + ] + + return ( + self.has_response_body and + len(successful_responses) > 1 and + len(self.success_status_code) != len(status_codes_for_responses_with_bodies) + ) + + @staticmethod def build_serialize_data_call(parameter: Parameter, function_name: str) -> str: diff --git a/autorest/codegen/models/paging_operation.py b/autorest/codegen/models/paging_operation.py index 75159bd0442..b64f9b2c2b2 100644 --- a/autorest/codegen/models/paging_operation.py +++ b/autorest/codegen/models/paging_operation.py @@ -93,6 +93,11 @@ def next_link_name(self) -> Optional[str]: return None return self._find_python_name(self._next_link_name, "nextLinkName") + @property + def has_optional_return_type(self) -> bool: + """A paging will never have an optional return type, we will always return ItemPaged[return type]""" + return False + def imports(self, code_model, async_mode: bool) -> FileImport: file_import = super(PagingOperation, self).imports(code_model, async_mode) diff --git a/autorest/codegen/templates/lro_operation.py.jinja2 b/autorest/codegen/templates/lro_operation.py.jinja2 index 3d3a9a4fdaf..80959e331e1 100644 --- a/autorest/codegen/templates/lro_operation.py.jinja2 +++ b/autorest/codegen/templates/lro_operation.py.jinja2 @@ -23,8 +23,7 @@ response_headers = { {% set return_type_wrapper = "" if async_mode else "LROPoller" %} {{ op_tools.method_signature(operation, operation_name, async_mode=async_mode, coroutine=async_mode, return_type_wrapper=return_type_wrapper) }} {%- if not async_mode %} -{# overriding sync_return_type_annotation because we know if it's sync, it's return type is just LROPoller #} - # type: (...) -> LROPoller + {{ op_tools.sync_return_type_annotation(operation, return_type_wrapper) }} {% endif %} """{{ operation.summary if operation.summary else operation.description | wordwrap(width=95, break_long_words=False, wrapstring='\n') }} {% if operation.summary and operation.description %} diff --git a/autorest/codegen/templates/operation.py.jinja2 b/autorest/codegen/templates/operation.py.jinja2 index da946a894f5..e120fd0aa44 100644 --- a/autorest/codegen/templates/operation.py.jinja2 +++ b/autorest/codegen/templates/operation.py.jinja2 @@ -62,7 +62,9 @@ {% if operation.any_response_has_headers %} response_headers = {} {% endif %} -{% if operation.has_response_body and operation.responses|count > 1 %} +{# now we only initialize deserialized to None if we know there is both > 1 response with body and > 1 response of None #} +{# otherwise, we know that deserialized will be set to a value then returned #} +{% if operation.has_optional_return_type %} deserialized = None {% endif %} {% if operation.has_response_body or operation.any_response_has_headers %} diff --git a/autorest/codegen/templates/operation_tools.jinja2 b/autorest/codegen/templates/operation_tools.jinja2 index c11bd91c041..ee97255cf5c 100644 --- a/autorest/codegen/templates/operation_tools.jinja2 +++ b/autorest/codegen/templates/operation_tools.jinja2 @@ -2,7 +2,7 @@ {% macro return_docstring(operation) %} {% if operation.responses | selectattr('has_body') | first %} :return: {{ operation.responses|selectattr('has_body')|map(attribute='schema')| map(attribute='docstring_text')|unique|join(' or ') }}, or the result of cls(response) -:rtype: {{ operation.responses|selectattr('has_body')|map(attribute='schema')| map(attribute='docstring_type')|unique|join(' or ') }}{{ " or None" if operation.responses|selectattr('has_body', 'false') | first }} +:rtype: {{ operation.responses|selectattr('has_body')|map(attribute='schema')| map(attribute='docstring_type')|unique|join(' or ') }}{{ " or None" if operation.has_optional_return_type }} {%- else %} :return: None, or the result of cls(response) :rtype: None @@ -37,11 +37,11 @@ :raises: ~azure.core.exceptions.HttpResponseError """{% endmacro %} {% macro return_type_annotation(operation, return_type_wrapper) %} -{{ ((return_type_wrapper + "[") if return_type_wrapper else "") ~ ("Union[" if operation.responses | selectattr('has_body') | map(attribute='schema') | map(attribute='operation_type_annotation') | unique | list | length > 1 else "") ~ +{{ ((return_type_wrapper + "[") if return_type_wrapper else "") ~ ("Optional[" if operation.has_optional_return_type else "" ) ~ ("Union[" if operation.responses | selectattr('has_body') | map(attribute='schema') | map(attribute='operation_type_annotation') | unique | list | length > 1 else "") ~ (operation.responses | selectattr('has_body') | map(attribute='schema') | map(attribute='operation_type_annotation') | unique | join(', ')) ~ -("]" if operation.responses | selectattr('has_body') | map(attribute='schema') | map(attribute='operation_type_annotation')| unique | list | length > 1 else "") ~ ( "]" if return_type_wrapper else "") +("]" if operation.responses | selectattr('has_body') | map(attribute='schema') | map(attribute='operation_type_annotation')| unique | list | length > 1 else "") ~ ("]" if operation.has_optional_return_type else "") ~ ( "]" if return_type_wrapper else "") if operation.responses | selectattr('has_body') | first -else ((return_type_wrapper + "[") if return_type_wrapper else "") ~ "None" ~ ( "]" if return_type_wrapper else "") }}{% endmacro %} +else ((return_type_wrapper + "[") if return_type_wrapper else "") ~ ("Optional[" if operation.has_optional_return_type else "" ) ~ "None" ~ ("]" if operation.has_optional_return_type else "") ~ ( "]" if return_type_wrapper else "") }}{% endmacro %} {# get async mypy typing #} {% macro async_return_type_annotation(operation, return_type_wrapper) %} {{ " -> " + return_type_annotation(operation, return_type_wrapper) }}{% endmacro %} diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations_async/_lr_os_custom_header_operations_async.py b/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations_async/_lr_os_custom_header_operations_async.py index 207673b826b..81f4384b62f 100644 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations_async/_lr_os_custom_header_operations_async.py +++ b/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations_async/_lr_os_custom_header_operations_async.py @@ -184,7 +184,6 @@ async def _put201_creating_succeeded200_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations_async/_lro_retrys_operations_async.py b/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations_async/_lro_retrys_operations_async.py index 99df448af14..bd77cc0ca9f 100644 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations_async/_lro_retrys_operations_async.py +++ b/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations_async/_lro_retrys_operations_async.py @@ -80,7 +80,6 @@ async def _put201_creating_succeeded200_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -273,7 +272,6 @@ async def _delete_provisioning202_accepted200_succeeded_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations_async/_lros_operations_async.py b/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations_async/_lros_operations_async.py index d00b089f273..f6dba33dd72 100644 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations_async/_lros_operations_async.py +++ b/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations_async/_lros_operations_async.py @@ -47,8 +47,8 @@ async def _put200_succeeded_initial( self, product: Optional["models.Product"] = None, **kwargs - ) -> "models.Product": - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + ) -> Optional["models.Product"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) content_type = kwargs.pop("content_type", "application/json") @@ -234,8 +234,8 @@ def get_long_running_output(pipeline_response): async def _post202_list_initial( self, **kwargs - ) -> List["models.Product"]: - cls = kwargs.pop('cls', None) # type: ClsType[List["models.Product"]] + ) -> Optional[List["models.Product"]]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional[List["models.Product"]]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) @@ -541,7 +541,6 @@ async def _put201_creating_succeeded200_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -734,7 +733,6 @@ async def _put201_creating_failed200_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -1895,7 +1893,6 @@ async def _delete_provisioning202_accepted200_succeeded_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -1987,7 +1984,6 @@ async def _delete_provisioning202_deleting_failed200_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -2079,7 +2075,6 @@ async def _delete_provisioning202_deletingcanceled200_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -2217,8 +2212,8 @@ def get_long_running_output(pipeline_response): async def _delete202_retry200_initial( self, **kwargs - ) -> "models.Product": - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + ) -> Optional["models.Product"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) @@ -2303,8 +2298,8 @@ def get_long_running_output(pipeline_response): async def _delete202_no_retry204_initial( self, **kwargs - ) -> "models.Product": - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + ) -> Optional["models.Product"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) @@ -2873,7 +2868,6 @@ async def _post200_with_payload_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Sku', pipeline_response) @@ -3364,8 +3358,8 @@ async def _post_async_retry_succeeded_initial( self, product: Optional["models.Product"] = None, **kwargs - ) -> "models.Product": - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + ) -> Optional["models.Product"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) content_type = kwargs.pop("content_type", "application/json") @@ -3466,8 +3460,8 @@ async def _post_async_no_retry_succeeded_initial( self, product: Optional["models.Product"] = None, **kwargs - ) -> "models.Product": - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + ) -> Optional["models.Product"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) content_type = kwargs.pop("content_type", "application/json") diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations_async/_lrosads_operations_async.py b/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations_async/_lrosads_operations_async.py index 68ac4526153..def8d856e50 100644 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations_async/_lrosads_operations_async.py +++ b/test/azure/Expected/AcceptanceTests/Lro/lro/aio/operations_async/_lrosads_operations_async.py @@ -80,7 +80,6 @@ async def _put_non_retry400_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -177,7 +176,6 @@ async def _put_non_retry201_creating400_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -275,7 +273,6 @@ async def _put_non_retry201_creating400_invalid_json_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -971,7 +968,6 @@ async def _put_error201_no_provisioning_state_payload_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -1571,8 +1567,8 @@ async def _put200_invalid_json_initial( self, product: Optional["models.Product"] = None, **kwargs - ) -> "models.Product": - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + ) -> Optional["models.Product"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) content_type = kwargs.pop("content_type", "application/json") diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lr_os_custom_header_operations.py b/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lr_os_custom_header_operations.py index d56f08c6720..67b75b212b5 100644 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lr_os_custom_header_operations.py +++ b/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lr_os_custom_header_operations.py @@ -103,7 +103,7 @@ def begin_put_async_retry_succeeded( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure- @@ -191,7 +191,6 @@ def _put201_creating_succeeded200_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -210,7 +209,7 @@ def begin_put201_creating_succeeded200( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll @@ -307,7 +306,7 @@ def begin_post202_retry200( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running post request, service returns a 202 to the initial request, with 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. @@ -401,7 +400,7 @@ def begin_post_async_retry_succeeded( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """x-ms-client-request-id = 9C4D50EE-2D56-4CD3-8152-34347DC9F2B0 is required message header for all requests. Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure- diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lro_retrys_operations.py b/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lro_retrys_operations.py index 0293a8419d9..5fd2009886f 100644 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lro_retrys_operations.py +++ b/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lro_retrys_operations.py @@ -85,7 +85,6 @@ def _put201_creating_succeeded200_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -104,7 +103,7 @@ def begin_put201_creating_succeeded200( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 500, then a 201 to the initial request, with an entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. @@ -204,7 +203,7 @@ def begin_put_async_relative_retry_succeeded( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 500, then a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure- AsyncOperation header for operation status. @@ -282,7 +281,6 @@ def _delete_provisioning202_accepted200_succeeded_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -302,7 +300,7 @@ def begin_delete_provisioning202_accepted200_succeeded( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running delete request, service returns a 500, then a 202 to the initial request, with an entity that contains ProvisioningState=’Accepted’. Polls return this value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. @@ -388,7 +386,7 @@ def begin_delete202_retry200( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete request, service returns a 500, then a 202 to the initial request. Polls return this value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. @@ -467,7 +465,7 @@ def begin_delete_async_relative_retry_succeeded( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete request, service returns a 500, then a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -556,7 +554,7 @@ def begin_post202_retry200( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running post request, service returns a 500, then a 202 to the initial request, with 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. @@ -649,7 +647,7 @@ def begin_post_async_relative_retry_succeeded( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running post request, service returns a 500, then a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure- AsyncOperation header for operation status. diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lros_operations.py b/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lros_operations.py index ad40f1fd5a4..5ec9eeb7881 100644 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lros_operations.py +++ b/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lros_operations.py @@ -52,8 +52,8 @@ def _put200_succeeded_initial( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> "models.Product" - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + # type: (...) -> Optional["models.Product"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) content_type = kwargs.pop("content_type", "application/json") @@ -101,7 +101,7 @@ def begin_put200_succeeded( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Succeeded’. @@ -196,7 +196,7 @@ def begin_put201_succeeded( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=’Succeeded’. @@ -243,8 +243,8 @@ def _post202_list_initial( self, **kwargs # type: Any ): - # type: (...) -> List["models.Product"] - cls = kwargs.pop('cls', None) # type: ClsType[List["models.Product"]] + # type: (...) -> Optional[List["models.Product"]] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[List["models.Product"]]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) @@ -287,7 +287,7 @@ def begin_post202_list( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[List["models.Product"]] """Long running put request, service returns a 202 with empty body to first request, returns a 200 with body [{ 'id': '100', 'name': 'foo' }]. @@ -379,7 +379,7 @@ def begin_put200_succeeded_no_state( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 200 to the initial request, with an entity that does not contain ProvisioningState=’Succeeded’. @@ -474,7 +474,7 @@ def begin_put202_retry200( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 202 to the initial request, with a location header that points to a polling URL that returns a 200 and an entity that doesn't contains ProvisioningState. @@ -556,7 +556,6 @@ def _put201_creating_succeeded200_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -575,7 +574,7 @@ def begin_put201_creating_succeeded200( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. @@ -671,7 +670,7 @@ def begin_put200_updating_succeeded204( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=’Updating’. Polls return this value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. @@ -753,7 +752,6 @@ def _put201_creating_failed200_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -772,7 +770,7 @@ def begin_put201_creating_failed200( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=’Created’. Polls return this value until the last poll returns a ‘200’ with ProvisioningState=’Failed’. @@ -868,7 +866,7 @@ def begin_put200_acceptedcanceled200( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 201 to the initial request, with an entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a ‘200’ with ProvisioningState=’Canceled’. @@ -966,7 +964,7 @@ def begin_put_no_header_in_retry( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 202 to the initial request with location header. Subsequent calls to operation status do not contain location header. @@ -1068,7 +1066,7 @@ def begin_put_async_retry_succeeded( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -1172,7 +1170,7 @@ def begin_put_async_no_retry_succeeded( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -1276,7 +1274,7 @@ def begin_put_async_retry_failed( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -1380,7 +1378,7 @@ def begin_put_async_no_retrycanceled( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -1482,7 +1480,7 @@ def begin_put_async_no_header_in_retry( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 202 to the initial request with Azure- AsyncOperation header. Subsequent calls to operation status do not contain Azure-AsyncOperation header. @@ -1581,7 +1579,7 @@ def begin_put_non_resource( sku=None, # type: Optional["models.Sku"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Sku"] """Long running put request with non resource. :param sku: sku to put. @@ -1675,7 +1673,7 @@ def begin_put_async_non_resource( sku=None, # type: Optional["models.Sku"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Sku"] """Long running put request with non resource. :param sku: Sku to put. @@ -1771,7 +1769,7 @@ def begin_put_sub_resource( provisioning_state=None, # type: Optional[str] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.SubProduct"] """Long running put request with sub resource. :param provisioning_state: @@ -1867,7 +1865,7 @@ def begin_put_async_sub_resource( provisioning_state=None, # type: Optional[str] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.SubProduct"] """Long running put request with sub resource. :param provisioning_state: @@ -1938,7 +1936,6 @@ def _delete_provisioning202_accepted200_succeeded_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -1958,7 +1955,7 @@ def begin_delete_provisioning202_accepted200_succeeded( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running delete request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Accepted’. Polls return this value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. @@ -2032,7 +2029,6 @@ def _delete_provisioning202_deleting_failed200_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -2052,7 +2048,7 @@ def begin_delete_provisioning202_deleting_failed200( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running delete request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a ‘200’ with ProvisioningState=’Failed’. @@ -2126,7 +2122,6 @@ def _delete_provisioning202_deletingcanceled200_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -2146,7 +2141,7 @@ def begin_delete_provisioning202_deletingcanceled200( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running delete request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. Polls return this value until the last poll returns a ‘200’ with ProvisioningState=’Canceled’. @@ -2228,7 +2223,7 @@ def begin_delete204_succeeded( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete succeeds and returns right away. :keyword callable cls: A custom type or function that will be passed the direct response @@ -2268,8 +2263,8 @@ def _delete202_retry200_initial( self, **kwargs # type: Any ): - # type: (...) -> "models.Product" - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + # type: (...) -> Optional["models.Product"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) @@ -2312,7 +2307,7 @@ def begin_delete202_retry200( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running delete request, service returns a 202 to the initial request. Polls return this value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. @@ -2356,8 +2351,8 @@ def _delete202_no_retry204_initial( self, **kwargs # type: Any ): - # type: (...) -> "models.Product" - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + # type: (...) -> Optional["models.Product"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) @@ -2400,7 +2395,7 @@ def begin_delete202_no_retry204( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running delete request, service returns a 202 to the initial request. Polls return this value until the last poll returns a ‘200’ with ProvisioningState=’Succeeded’. @@ -2481,7 +2476,7 @@ def begin_delete_no_header_in_retry( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete request, service returns a location header in the initial request. Subsequent calls to operation status do not contain location header. @@ -2559,7 +2554,7 @@ def begin_delete_async_no_header_in_retry( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete request, service returns an Azure-AsyncOperation header in the initial request. Subsequent calls to operation status do not contain Azure-AsyncOperation header. @@ -2638,7 +2633,7 @@ def begin_delete_async_retry_succeeded( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -2717,7 +2712,7 @@ def begin_delete_async_no_retry_succeeded( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -2796,7 +2791,7 @@ def begin_delete_async_retry_failed( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -2875,7 +2870,7 @@ def begin_delete_async_retrycanceled( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -2940,7 +2935,6 @@ def _post200_with_payload_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Sku', pipeline_response) @@ -2958,7 +2952,7 @@ def begin_post200_with_payload( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Sku"] """Long running post request, service returns a 202 to the initial request, with 'Location' header. Poll returns a 200 with a response body after success. @@ -3050,7 +3044,7 @@ def begin_post202_retry200( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running post request, service returns a 202 to the initial request, with 'Location' and 'Retry-After' headers, Polls return a 200 with a response body after success. @@ -3145,7 +3139,7 @@ def begin_post202_no_retry204( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running post request, service returns a 202 to the initial request, with 'Location' header, 204 with noresponse body after success. @@ -3233,7 +3227,7 @@ def begin_post_double_headers_final_location_get( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running post request, service returns a 202 to the initial request with both Location and Azure-Async header. Poll Azure-Async and it's success. Should poll Location to get the final object. @@ -3315,7 +3309,7 @@ def begin_post_double_headers_final_azure_header_get( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running post request, service returns a 202 to the initial request with both Location and Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the final object. @@ -3397,7 +3391,7 @@ def begin_post_double_headers_final_azure_header_get_default( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running post request, service returns a 202 to the initial request with both Location and Azure-Async header. Poll Azure-Async and it's success. Should NOT poll Location to get the final object if you support initial Autorest behavior. @@ -3443,8 +3437,8 @@ def _post_async_retry_succeeded_initial( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> "models.Product" - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + # type: (...) -> Optional["models.Product"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) content_type = kwargs.pop("content_type", "application/json") @@ -3498,7 +3492,7 @@ def begin_post_async_retry_succeeded( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -3547,8 +3541,8 @@ def _post_async_no_retry_succeeded_initial( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> "models.Product" - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + # type: (...) -> Optional["models.Product"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) content_type = kwargs.pop("content_type", "application/json") @@ -3602,7 +3596,7 @@ def begin_post_async_no_retry_succeeded( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -3699,7 +3693,7 @@ def begin_post_async_retry_failed( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -3793,7 +3787,7 @@ def begin_post_async_retrycanceled( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. diff --git a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lrosads_operations.py b/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lrosads_operations.py index 8fe55082e2d..39068234a8e 100644 --- a/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lrosads_operations.py +++ b/test/azure/Expected/AcceptanceTests/Lro/lro/operations/_lrosads_operations.py @@ -85,7 +85,6 @@ def _put_non_retry400_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -104,7 +103,7 @@ def begin_put_non_retry400( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 400 to the initial request. :param product: Product to put. @@ -184,7 +183,6 @@ def _put_non_retry201_creating400_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -203,7 +201,7 @@ def begin_put_non_retry201_creating400( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and 201 response code. @@ -284,7 +282,6 @@ def _put_non_retry201_creating400_invalid_json_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -303,7 +300,7 @@ def begin_put_non_retry201_creating400_invalid_json( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a Product with 'ProvisioningState' = 'Creating' and 201 response code. @@ -402,7 +399,7 @@ def begin_put_async_relative_retry400( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 200 with ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -491,7 +488,7 @@ def begin_delete_non_retry400( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete request, service returns a 400 with an error body. :keyword callable cls: A custom type or function that will be passed the direct response @@ -568,7 +565,7 @@ def begin_delete202_non_retry400( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete request, service returns a 202 with a location header. :keyword callable cls: A custom type or function that will be passed the direct response @@ -646,7 +643,7 @@ def begin_delete_async_relative_retry400( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -735,7 +732,7 @@ def begin_post_non_retry400( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running post request, service returns a 400 with no error body. :param product: Product to put. @@ -826,7 +823,7 @@ def begin_post202_non_retry400( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running post request, service returns a 202 with a location header. :param product: Product to put. @@ -918,7 +915,7 @@ def begin_post_async_relative_retry400( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running post request, service returns a 202 to the initial request Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -996,7 +993,6 @@ def _put_error201_no_provisioning_state_payload_initial( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('Product', pipeline_response) @@ -1015,7 +1011,7 @@ def begin_put_error201_no_provisioning_state_payload( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 201 to the initial request with no payload. :param product: Product to put. @@ -1113,7 +1109,7 @@ def begin_put_async_relative_retry_no_status( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -1218,7 +1214,7 @@ def begin_put_async_relative_retry_no_status_payload( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -1304,7 +1300,7 @@ def begin_delete204_succeeded( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete request, service returns a 204 to the initial request, indicating success. :keyword callable cls: A custom type or function that will be passed the direct response @@ -1382,7 +1378,7 @@ def begin_delete_async_relative_retry_no_status( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -1471,7 +1467,7 @@ def begin_post202_no_location( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running post request, service returns a 202 to the initial request, without a location header. @@ -1564,7 +1560,7 @@ def begin_post_async_relative_retry_no_payload( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -1610,8 +1606,8 @@ def _put200_invalid_json_initial( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> "models.Product" - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + # type: (...) -> Optional["models.Product"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) content_type = kwargs.pop("content_type", "application/json") @@ -1659,7 +1655,7 @@ def begin_put200_invalid_json( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 200 to the initial request, with an entity that is not a valid json. @@ -1758,7 +1754,7 @@ def begin_put_async_relative_retry_invalid_header( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation header is invalid. @@ -1863,7 +1859,7 @@ def begin_put_async_relative_retry_invalid_json_polling( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Long running put request, service returns a 200 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -1953,7 +1949,7 @@ def begin_delete202_retry_invalid_header( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete request, service returns a 202 to the initial request receing a reponse with an invalid 'Location' and 'Retry-After' headers. @@ -2032,7 +2028,7 @@ def begin_delete_async_relative_retry_invalid_header( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete request, service returns a 202 to the initial request. The endpoint indicated in the Azure-AsyncOperation header is invalid. @@ -2111,7 +2107,7 @@ def begin_delete_async_relative_retry_invalid_json_polling( self, **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running delete request, service returns a 202 to the initial request. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. @@ -2200,7 +2196,7 @@ def begin_post202_retry_invalid_header( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running post request, service returns a 202 to the initial request, with invalid 'Location' and 'Retry-After' headers. @@ -2293,7 +2289,7 @@ def begin_post_async_relative_retry_invalid_header( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. The endpoint indicated in the Azure-AsyncOperation header is invalid. @@ -2387,7 +2383,7 @@ def begin_post_async_relative_retry_invalid_json_polling( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller[None] """Long running post request, service returns a 202 to the initial request, with an entity that contains ProvisioningState=’Creating’. Poll the endpoint indicated in the Azure-AsyncOperation header for operation status. diff --git a/test/azure/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py b/test/azure/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py index e228bf9585d..2633402d021 100644 --- a/test/azure/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py +++ b/test/azure/Expected/AcceptanceTests/Paging/paging/operations/_paging_operations.py @@ -1045,7 +1045,7 @@ def begin_get_multiple_pages_lro( paging_get_multiple_pages_lro_options=None, # type: Optional["models.PagingGetMultiplePagesLroOptions"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.ProductResult"] """A long-running paging operation that includes a nextLink that has 10 pages. :param client_request_id: diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations_async/_storage_accounts_operations_async.py b/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations_async/_storage_accounts_operations_async.py index 759d38466e4..08f3d93e286 100644 --- a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations_async/_storage_accounts_operations_async.py +++ b/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/aio/operations_async/_storage_accounts_operations_async.py @@ -111,8 +111,8 @@ async def _create_initial( account_name: str, parameters: "models.StorageAccountCreateParameters", **kwargs - ) -> "models.StorageAccount": - cls = kwargs.pop('cls', None) # type: ClsType["models.StorageAccount"] + ) -> Optional["models.StorageAccount"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.StorageAccount"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) api_version = "2015-05-01-preview" diff --git a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py b/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py index 4b90634be09..d0fb6366e48 100644 --- a/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py +++ b/test/azure/Expected/AcceptanceTests/StorageManagementClient/storage/operations/_storage_accounts_operations.py @@ -116,8 +116,8 @@ def _create_initial( parameters, # type: "models.StorageAccountCreateParameters" **kwargs # type: Any ): - # type: (...) -> "models.StorageAccount" - cls = kwargs.pop('cls', None) # type: ClsType["models.StorageAccount"] + # type: (...) -> Optional["models.StorageAccount"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.StorageAccount"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) api_version = "2015-05-01-preview" @@ -172,7 +172,7 @@ def begin_create( parameters, # type: "models.StorageAccountCreateParameters" **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.StorageAccount"] """Asynchronously creates a new storage account with the specified parameters. Existing accounts cannot be updated with this API and should instead use the Update Storage Account API. If an account is already created and subsequent PUT request is issued with exact same set of diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_operations_mixin.py index e53cbcf6409..6b1c68b498a 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/_operations_mixin.py @@ -35,7 +35,7 @@ def begin_test_lro( :type product: ~multiapi.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :return: Product, or the result of cls(response) - :rtype: ~multiapi.v1.models.Product or None + :rtype: ~multiapi.v1.models.Product :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro') diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/aio/_operations_mixin_async.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/aio/_operations_mixin_async.py index 2643b77915a..ff9806f0565 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/aio/_operations_mixin_async.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/aio/_operations_mixin_async.py @@ -31,7 +31,7 @@ async def test_lro( :type product: ~multiapi.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :return: Product, or the result of cls(response) - :rtype: ~multiapi.v1.models.Product or None + :rtype: ~multiapi.v1.models.Product :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('test_lro') diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_metadata.json b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_metadata.json index da28e75e0f7..09e2553a708 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/_metadata.json @@ -55,7 +55,7 @@ }, "async": { "operation_name": "_test_lro_initial", - "signature": "async def _test_lro_initial(\n self,\n product: Optional[\"models.Product\"] = None,\n **kwargs\n) -\u003e \"models.Product\":\n", + "signature": "async def _test_lro_initial(\n self,\n product: Optional[\"models.Product\"] = None,\n **kwargs\n) -\u003e Optional[\"models.Product\"]:\n", "coroutine": true }, "doc": " \"\"\"\n\n:param product: Product to put.\n:type product: ~multiapi.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapi.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", @@ -71,7 +71,7 @@ "signature": "async def test_lro(\n self,\n product: Optional[\"models.Product\"] = None,\n **kwargs\n) -\u003e \"models.Product\":\n", "coroutine": true }, - "doc": " \"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapi.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapi.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "doc": " \"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapi.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapi.v1.models.Product\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", "call": "product" } }, diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations_async/_multiapi_service_client_operations_async.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations_async/_multiapi_service_client_operations_async.py index d5c0d0fbdd8..4979a8bd9d8 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations_async/_multiapi_service_client_operations_async.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/aio/operations_async/_multiapi_service_client_operations_async.py @@ -75,8 +75,8 @@ async def _test_lro_initial( self, product: Optional["models.Product"] = None, **kwargs - ) -> "models.Product": - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + ) -> Optional["models.Product"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) content_type = kwargs.pop("content_type", "application/json") diff --git a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_multiapi_service_client_operations.py index 7022122ecc6..56129e5d84a 100644 --- a/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/Multiapi/multiapi/v1/operations/_multiapi_service_client_operations.py @@ -81,8 +81,8 @@ def _test_lro_initial( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> "models.Product" - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + # type: (...) -> Optional["models.Product"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) content_type = kwargs.pop("content_type", "application/json") @@ -130,7 +130,7 @@ def begin_test_lro( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Put in whatever shape of Product you want, will return a Product with id equal to 100. :param product: Product to put. diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_operations_mixin.py index 389fa6cc5a1..2e42114fc77 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/_operations_mixin.py @@ -35,7 +35,7 @@ def begin_test_lro( :type product: ~multiapinoasync.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :return: Product, or the result of cls(response) - :rtype: ~multiapinoasync.v1.models.Product or None + :rtype: ~multiapinoasync.v1.models.Product :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro') diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_metadata.json index 13d316b5b54..f62586bc099 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/_metadata.json @@ -55,7 +55,7 @@ }, "async": { "operation_name": "_test_lro_initial", - "signature": "async def _test_lro_initial(\n self,\n product: Optional[\"models.Product\"] = None,\n **kwargs\n) -\u003e \"models.Product\":\n", + "signature": "async def _test_lro_initial(\n self,\n product: Optional[\"models.Product\"] = None,\n **kwargs\n) -\u003e Optional[\"models.Product\"]:\n", "coroutine": true }, "doc": " \"\"\"\n\n:param product: Product to put.\n:type product: ~multiapinoasync.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapinoasync.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", @@ -71,7 +71,7 @@ "signature": "async def test_lro(\n self,\n product: Optional[\"models.Product\"] = None,\n **kwargs\n) -\u003e \"models.Product\":\n", "coroutine": true }, - "doc": " \"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapinoasync.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapinoasync.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "doc": " \"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapinoasync.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapinoasync.v1.models.Product\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", "call": "product" } }, diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_multiapi_service_client_operations.py index aec83d743b0..e432423c498 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiNoAsync/multiapinoasync/v1/operations/_multiapi_service_client_operations.py @@ -81,8 +81,8 @@ def _test_lro_initial( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> "models.Product" - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + # type: (...) -> Optional["models.Product"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) content_type = kwargs.pop("content_type", "application/json") @@ -130,7 +130,7 @@ def begin_test_lro( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Put in whatever shape of Product you want, will return a Product with id equal to 100. :param product: Product to put. diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_operations_mixin.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_operations_mixin.py index 07febfed3c6..28242d4821e 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_operations_mixin.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/_operations_mixin.py @@ -35,7 +35,7 @@ def begin_test_lro( :type product: ~multiapiwithsubmodule.submodule.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :return: Product, or the result of cls(response) - :rtype: ~multiapiwithsubmodule.submodule.v1.models.Product or None + :rtype: ~multiapiwithsubmodule.submodule.v1.models.Product :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('begin_test_lro') diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_operations_mixin_async.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_operations_mixin_async.py index 11552e376da..861f39616b1 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_operations_mixin_async.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/aio/_operations_mixin_async.py @@ -31,7 +31,7 @@ async def test_lro( :type product: ~multiapiwithsubmodule.submodule.v1.models.Product :keyword callable cls: A custom type or function that will be passed the direct response :return: Product, or the result of cls(response) - :rtype: ~multiapiwithsubmodule.submodule.v1.models.Product or None + :rtype: ~multiapiwithsubmodule.submodule.v1.models.Product :raises: ~azure.core.exceptions.HttpResponseError """ api_version = self._get_api_version('test_lro') diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_metadata.json b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_metadata.json index 76bbd74decf..c9bc7978120 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_metadata.json +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/_metadata.json @@ -55,7 +55,7 @@ }, "async": { "operation_name": "_test_lro_initial", - "signature": "async def _test_lro_initial(\n self,\n product: Optional[\"models.Product\"] = None,\n **kwargs\n) -\u003e \"models.Product\":\n", + "signature": "async def _test_lro_initial(\n self,\n product: Optional[\"models.Product\"] = None,\n **kwargs\n) -\u003e Optional[\"models.Product\"]:\n", "coroutine": true }, "doc": " \"\"\"\n\n:param product: Product to put.\n:type product: ~multiapiwithsubmodule.submodule.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapiwithsubmodule.submodule.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", @@ -71,7 +71,7 @@ "signature": "async def test_lro(\n self,\n product: Optional[\"models.Product\"] = None,\n **kwargs\n) -\u003e \"models.Product\":\n", "coroutine": true }, - "doc": " \"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapiwithsubmodule.submodule.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapiwithsubmodule.submodule.v1.models.Product or None\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", + "doc": " \"\"\"Put in whatever shape of Product you want, will return a Product with id equal to 100.\n\n:param product: Product to put.\n:type product: ~multiapiwithsubmodule.submodule.v1.models.Product\n:keyword callable cls: A custom type or function that will be passed the direct response\n:return: Product, or the result of cls(response)\n:rtype: ~multiapiwithsubmodule.submodule.v1.models.Product\n:raises: ~azure.core.exceptions.HttpResponseError\n\"\"\"", "call": "product" } }, diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations_async/_multiapi_service_client_operations_async.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations_async/_multiapi_service_client_operations_async.py index 1ecf28682de..3c88e3c917e 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations_async/_multiapi_service_client_operations_async.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/aio/operations_async/_multiapi_service_client_operations_async.py @@ -75,8 +75,8 @@ async def _test_lro_initial( self, product: Optional["models.Product"] = None, **kwargs - ) -> "models.Product": - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + ) -> Optional["models.Product"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) content_type = kwargs.pop("content_type", "application/json") diff --git a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_multiapi_service_client_operations.py b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_multiapi_service_client_operations.py index 65a9decd18f..385a5e0f12c 100644 --- a/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_multiapi_service_client_operations.py +++ b/test/multiapi/Expected/AcceptanceTests/MultiapiWithSubmodule/multiapiwithsubmodule/submodule/v1/operations/_multiapi_service_client_operations.py @@ -81,8 +81,8 @@ def _test_lro_initial( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> "models.Product" - cls = kwargs.pop('cls', None) # type: ClsType["models.Product"] + # type: (...) -> Optional["models.Product"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Product"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) content_type = kwargs.pop("content_type", "application/json") @@ -130,7 +130,7 @@ def begin_test_lro( product=None, # type: Optional["models.Product"] **kwargs # type: Any ): - # type: (...) -> LROPoller + # type: (...) -> LROPoller["models.Product"] """Put in whatever shape of Product you want, will return a Product with id equal to 100. :param product: Product to put. diff --git a/test/unittests/test_optional_return_type.py b/test/unittests/test_optional_return_type.py new file mode 100644 index 00000000000..8528b802b6f --- /dev/null +++ b/test/unittests/test_optional_return_type.py @@ -0,0 +1,120 @@ +# ------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# -------------------------------------------------------------------------- + +import pytest +from autorest.codegen.models import Operation, LROOperation, PagingOperation, SchemaResponse, CodeModel + +@pytest.fixture +def operation(): + return Operation( + yaml_data={}, + name="optional_return_type_test", + description="Operation to test optional return types", + url="http://www.optional_return_type.com", + method="method", + api_versions=set(["2020-05-01"]), + requests=[] + ) + +@pytest.fixture +def lro_operation(): + return LROOperation( + yaml_data={}, + name="lro_optional_return_type_test", + description="LRO Operation to test optional return types", + url="http://www.optional_return_type.com", + method="method", + api_versions=set(["2020-05-01"]), + requests=[] + ) + +@pytest.fixture +def paging_operation(): + return PagingOperation( + yaml_data={"extensions": {"x-ms-pageable": {}}}, + name="paging_optional_return_type_test", + description="Paging Operation to test optional return types", + url="http://www.optional_return_type.com", + method="method", + api_versions=set(["2020-05-01"]), + requests=[] + ) + +def test_success_with_body_and_fail_no_body(operation): + operation.responses = [ + SchemaResponse( + yaml_data={}, media_types=["application/xml", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=[200] + ), + SchemaResponse( + yaml_data={}, media_types=["application/xml", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=[202] + ), + SchemaResponse( + yaml_data={}, media_types=["application/json", "text/json"], headers=[], binary=False, schema=None, status_codes=["default"] + ) + ] + + assert operation.has_optional_return_type is False + +def test_success_no_body_fail_with_body(operation): + operation.responses = [ + SchemaResponse( + yaml_data={}, media_types=["application/xml", "text/json"], headers=[], binary=False, schema=None, status_codes=[200] + ), + SchemaResponse( + yaml_data={}, media_types=["application/json", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=["default"] + ) + ] + + assert operation.has_optional_return_type is False + +def test_optional_return_type_operation(operation): + operation.responses = [ + SchemaResponse( + yaml_data={}, media_types=["application/xml", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=[200] + ), + SchemaResponse( + yaml_data={}, media_types=["application/json", "text/json"], headers=[], binary=False, schema=None, status_codes=[202] + ), + SchemaResponse( + yaml_data={}, media_types=["application/json", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=["default"] + ) + ] + + assert operation.has_optional_return_type is True + +def test_lro_operation(lro_operation): + lro_operation.responses = [ + SchemaResponse( + yaml_data={}, media_types=["application/xml", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=[200] + ), + SchemaResponse( + yaml_data={}, media_types=["application/json", "text/json"], headers=[], binary=False, schema=None, status_codes=[202] + ), + SchemaResponse( + yaml_data={}, media_types=["application/json", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=["default"] + ) + ] + + assert lro_operation.has_optional_return_type is False + + lro_initial_function = CodeModel._lro_initial_function(lro_operation) + + assert lro_initial_function.has_optional_return_type is True + +def test_paging_operation(paging_operation): + paging_operation.responses = [ + SchemaResponse( + yaml_data={}, media_types=["application/xml", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=[200] + ), + SchemaResponse( + yaml_data={}, media_types=["application/json", "text/json"], headers=[], binary=False, schema=None, status_codes=[202] + ), + SchemaResponse( + yaml_data={}, media_types=["application/json", "text/json"], headers=[], binary=False, schema={"a": "b"}, status_codes=["default"] + ) + ] + + assert paging_operation.has_optional_return_type is False diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations_async/_http_redirects_operations_async.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations_async/_http_redirects_operations_async.py index d47b87c797d..5339cc0aef1 100644 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations_async/_http_redirects_operations_async.py +++ b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations_async/_http_redirects_operations_async.py @@ -88,7 +88,7 @@ async def head300( async def get300( self, **kwargs - ) -> List[str]: + ) -> Optional[List[str]]: """Return 300 status code and redirect to /http/success/200. :keyword callable cls: A custom type or function that will be passed the direct response @@ -96,7 +96,7 @@ async def get300( :rtype: list[str] or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List[str]] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[List[str]]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations_async/_multiple_responses_operations_async.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations_async/_multiple_responses_operations_async.py index eee73fdcbb1..60c2fc4a5b4 100644 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations_async/_multiple_responses_operations_async.py +++ b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/aio/operations_async/_multiple_responses_operations_async.py @@ -44,7 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get200_model204_no_model_default_error200_valid( self, **kwargs - ) -> "models.MyException": + ) -> Optional["models.MyException"]: """Send a 200 response with valid payload: {'statusCode': '200'}. :keyword callable cls: A custom type or function that will be passed the direct response @@ -52,7 +52,7 @@ async def get200_model204_no_model_default_error200_valid( :rtype: ~httpinfrastructure.models.MyException or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.MyException"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.MyException"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) @@ -90,7 +90,7 @@ async def get200_model204_no_model_default_error200_valid( async def get200_model204_no_model_default_error204_valid( self, **kwargs - ) -> "models.MyException": + ) -> Optional["models.MyException"]: """Send a 204 response with no payload. :keyword callable cls: A custom type or function that will be passed the direct response @@ -98,7 +98,7 @@ async def get200_model204_no_model_default_error204_valid( :rtype: ~httpinfrastructure.models.MyException or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.MyException"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.MyException"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) @@ -136,7 +136,7 @@ async def get200_model204_no_model_default_error204_valid( async def get200_model204_no_model_default_error201_invalid( self, **kwargs - ) -> "models.MyException": + ) -> Optional["models.MyException"]: """Send a 201 response with valid payload: {'statusCode': '201'}. :keyword callable cls: A custom type or function that will be passed the direct response @@ -144,7 +144,7 @@ async def get200_model204_no_model_default_error201_invalid( :rtype: ~httpinfrastructure.models.MyException or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.MyException"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.MyException"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) @@ -182,7 +182,7 @@ async def get200_model204_no_model_default_error201_invalid( async def get200_model204_no_model_default_error202_none( self, **kwargs - ) -> "models.MyException": + ) -> Optional["models.MyException"]: """Send a 202 response with no payload:. :keyword callable cls: A custom type or function that will be passed the direct response @@ -190,7 +190,7 @@ async def get200_model204_no_model_default_error202_none( :rtype: ~httpinfrastructure.models.MyException or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.MyException"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.MyException"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) @@ -228,7 +228,7 @@ async def get200_model204_no_model_default_error202_none( async def get200_model204_no_model_default_error400_valid( self, **kwargs - ) -> "models.MyException": + ) -> Optional["models.MyException"]: """Send a 400 response with valid error payload: {'status': 400, 'message': 'client error'}. :keyword callable cls: A custom type or function that will be passed the direct response @@ -236,7 +236,7 @@ async def get200_model204_no_model_default_error400_valid( :rtype: ~httpinfrastructure.models.MyException or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.MyException"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.MyException"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) @@ -306,7 +306,6 @@ async def get200_model201_model_default_error200_valid( error = self._deserialize(models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('MyException', pipeline_response) @@ -355,7 +354,6 @@ async def get200_model201_model_default_error201_valid( error = self._deserialize(models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('MyException', pipeline_response) @@ -404,7 +402,6 @@ async def get200_model201_model_default_error400_valid( error = self._deserialize(models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('MyException', pipeline_response) @@ -453,7 +450,6 @@ async def get200_model_a201_model_c404_model_d_default_error200_valid( error = self._deserialize(models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('MyException', pipeline_response) @@ -505,7 +501,6 @@ async def get200_model_a201_model_c404_model_d_default_error201_valid( error = self._deserialize(models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('MyException', pipeline_response) @@ -557,7 +552,6 @@ async def get200_model_a201_model_c404_model_d_default_error404_valid( error = self._deserialize(models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('MyException', pipeline_response) @@ -609,7 +603,6 @@ async def get200_model_a201_model_c404_model_d_default_error400_valid( error = self._deserialize(models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('MyException', pipeline_response) diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_redirects_operations.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_redirects_operations.py index 77a226d12b6..45af93c2e77 100644 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_redirects_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_http_redirects_operations.py @@ -94,7 +94,7 @@ def get300( self, **kwargs # type: Any ): - # type: (...) -> List[str] + # type: (...) -> Optional[List[str]] """Return 300 status code and redirect to /http/success/200. :keyword callable cls: A custom type or function that will be passed the direct response @@ -102,7 +102,7 @@ def get300( :rtype: list[str] or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[List[str]] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[List[str]]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) diff --git a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_multiple_responses_operations.py b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_multiple_responses_operations.py index 0cb38f57e2d..97ea5baab15 100644 --- a/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_multiple_responses_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/Http/httpinfrastructure/operations/_multiple_responses_operations.py @@ -49,7 +49,7 @@ def get200_model204_no_model_default_error200_valid( self, **kwargs # type: Any ): - # type: (...) -> "models.MyException" + # type: (...) -> Optional["models.MyException"] """Send a 200 response with valid payload: {'statusCode': '200'}. :keyword callable cls: A custom type or function that will be passed the direct response @@ -57,7 +57,7 @@ def get200_model204_no_model_default_error200_valid( :rtype: ~httpinfrastructure.models.MyException or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.MyException"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.MyException"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) @@ -96,7 +96,7 @@ def get200_model204_no_model_default_error204_valid( self, **kwargs # type: Any ): - # type: (...) -> "models.MyException" + # type: (...) -> Optional["models.MyException"] """Send a 204 response with no payload. :keyword callable cls: A custom type or function that will be passed the direct response @@ -104,7 +104,7 @@ def get200_model204_no_model_default_error204_valid( :rtype: ~httpinfrastructure.models.MyException or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.MyException"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.MyException"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) @@ -143,7 +143,7 @@ def get200_model204_no_model_default_error201_invalid( self, **kwargs # type: Any ): - # type: (...) -> "models.MyException" + # type: (...) -> Optional["models.MyException"] """Send a 201 response with valid payload: {'statusCode': '201'}. :keyword callable cls: A custom type or function that will be passed the direct response @@ -151,7 +151,7 @@ def get200_model204_no_model_default_error201_invalid( :rtype: ~httpinfrastructure.models.MyException or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.MyException"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.MyException"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) @@ -190,7 +190,7 @@ def get200_model204_no_model_default_error202_none( self, **kwargs # type: Any ): - # type: (...) -> "models.MyException" + # type: (...) -> Optional["models.MyException"] """Send a 202 response with no payload:. :keyword callable cls: A custom type or function that will be passed the direct response @@ -198,7 +198,7 @@ def get200_model204_no_model_default_error202_none( :rtype: ~httpinfrastructure.models.MyException or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.MyException"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.MyException"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) @@ -237,7 +237,7 @@ def get200_model204_no_model_default_error400_valid( self, **kwargs # type: Any ): - # type: (...) -> "models.MyException" + # type: (...) -> Optional["models.MyException"] """Send a 400 response with valid error payload: {'status': 400, 'message': 'client error'}. :keyword callable cls: A custom type or function that will be passed the direct response @@ -245,7 +245,7 @@ def get200_model204_no_model_default_error400_valid( :rtype: ~httpinfrastructure.models.MyException or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.MyException"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.MyException"]] error_map = {404: ResourceNotFoundError, 409: ResourceExistsError} error_map.update(kwargs.pop('error_map', {})) @@ -316,7 +316,6 @@ def get200_model201_model_default_error200_valid( error = self._deserialize(models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('MyException', pipeline_response) @@ -366,7 +365,6 @@ def get200_model201_model_default_error201_valid( error = self._deserialize(models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('MyException', pipeline_response) @@ -416,7 +414,6 @@ def get200_model201_model_default_error400_valid( error = self._deserialize(models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('MyException', pipeline_response) @@ -466,7 +463,6 @@ def get200_model_a201_model_c404_model_d_default_error200_valid( error = self._deserialize(models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('MyException', pipeline_response) @@ -519,7 +515,6 @@ def get200_model_a201_model_c404_model_d_default_error201_valid( error = self._deserialize(models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('MyException', pipeline_response) @@ -572,7 +567,6 @@ def get200_model_a201_model_c404_model_d_default_error404_valid( error = self._deserialize(models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('MyException', pipeline_response) @@ -625,7 +619,6 @@ def get200_model_a201_model_c404_model_d_default_error400_valid( error = self._deserialize(models.Error, response) raise HttpResponseError(response=response, model=error) - deserialized = None if response.status_code == 200: deserialized = self._deserialize('MyException', pipeline_response) diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations_async/_pet_operations_async.py b/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations_async/_pet_operations_async.py index 767bc6a11d2..0c4d28e775f 100644 --- a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations_async/_pet_operations_async.py +++ b/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/aio/operations_async/_pet_operations_async.py @@ -45,7 +45,7 @@ async def get_pet_by_id( self, pet_id: str, **kwargs - ) -> "models.Pet": + ) -> Optional["models.Pet"]: """Gets pets by id. :param pet_id: pet id. @@ -55,7 +55,7 @@ async def get_pet_by_id( :rtype: ~xmserrorresponse.models.Pet or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Pet"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Pet"]] error_map = { 409: ResourceExistsError, 400: HttpResponseError, diff --git a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/_pet_operations.py b/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/_pet_operations.py index ce67512cef4..d92e436ca80 100644 --- a/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/_pet_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/XmsErrorResponse/xmserrorresponse/operations/_pet_operations.py @@ -50,7 +50,7 @@ def get_pet_by_id( pet_id, # type: str **kwargs # type: Any ): - # type: (...) -> "models.Pet" + # type: (...) -> Optional["models.Pet"] """Gets pets by id. :param pet_id: pet id. @@ -60,7 +60,7 @@ def get_pet_by_id( :rtype: ~xmserrorresponse.models.Pet or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["models.Pet"] + cls = kwargs.pop('cls', None) # type: ClsType[Optional["models.Pet"]] error_map = { 409: ResourceExistsError, 400: HttpResponseError,