diff --git a/autorest/codegen/models/parameter.py b/autorest/codegen/models/parameter.py index 8930373629b..db9ceacafc3 100644 --- a/autorest/codegen/models/parameter.py +++ b/autorest/codegen/models/parameter.py @@ -94,6 +94,20 @@ def constant(self) -> bool: return False return self.required + @property + def constant_declaration(self) -> str: + if self.schema: + if isinstance(self.schema, ConstantSchema): + return self.schema.get_declaration(self.schema.value) + raise ValueError( + "Trying to get constant declaration for a schema that is not ConstantSchema" + ) + raise ValueError("Trying to get a declaration for a schema that doesn't exist") + + @property + def xml_serialization_ctxt(self) -> str: + return self.schema.xml_serialization_ctxt() or "" + @property def in_method_signature(self) -> bool: return not( @@ -153,6 +167,10 @@ def default_value(self) -> Optional[Any]: # default values we bubble up from the schema return self._default_value()[0] + @property + def serialization_type(self) -> str: + return self.schema.serialization_type + @property def docstring_type(self) -> str: return self.multiple_media_types_docstring_type or self.schema.docstring_type diff --git a/autorest/codegen/models/property.py b/autorest/codegen/models/property.py index bc2b57db020..055e7f4008a 100644 --- a/autorest/codegen/models/property.py +++ b/autorest/codegen/models/property.py @@ -76,6 +76,26 @@ def from_yaml(cls, yaml_data: Dict[str, Any], **kwargs) -> "Property": flattened_names=yaml_data.get("flattenedNames", []), ) + @property + def constant_declaration(self) -> str: + if self.schema: + if isinstance(self.schema, ConstantSchema): + return self.schema.get_declaration(self.schema.value) + raise ValueError( + "Trying to get constant declaration for a schema that is not ConstantSchema" + ) + raise ValueError("Trying to get a declaration for a schema that doesn't exist") + + @property + def serialization_type(self) -> str: + return self.schema.serialization_type + + @property + def xml_metadata(self) -> str: + if self.schema.has_xml_serialization_ctxt: + return f", 'xml': {{{self.schema.xml_serialization_ctxt()}}}" + return "" + @property def type_annotation(self) -> str: if self.required: diff --git a/autorest/codegen/models/schema_response.py b/autorest/codegen/models/schema_response.py index bb549711781..25aba13227b 100644 --- a/autorest/codegen/models/schema_response.py +++ b/autorest/codegen/models/schema_response.py @@ -3,10 +3,11 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from typing import Dict, Optional, List, Union, Any +from typing import Dict, Optional, List, Union, Any, cast from .base_model import BaseModel from .base_schema import BaseSchema +from .object_schema import ObjectSchema class HeaderResponse: @@ -14,6 +15,10 @@ def __init__(self, name: str, schema) -> None: self.name = name self.schema = schema + @property + def serialization_type(self) -> str: + return self.schema.serialization_type + class SchemaResponse(BaseModel): def __init__( @@ -31,6 +36,7 @@ def __init__( self.status_codes = status_codes self.headers = headers self.binary = binary + self.nullable = self.yaml_data.get("nullable", False) @property def has_body(self) -> bool: @@ -44,11 +50,47 @@ def has_headers(self) -> bool: """ return bool(self.headers) + @property + def serialization_type(self) -> str: + if self.schema: + return self.schema.serialization_type + return "None" + + @property + def operation_type_annotation(self) -> str: + if not self.schema: + return "None" + if self.nullable: + return f"Optional[{self.schema.operation_type_annotation}]" + return self.schema.operation_type_annotation + + @property + def docstring_text(self) -> str: + if not self.schema: + return "None" + if self.nullable: + return f"{self.schema.docstring_text} or None" + return self.schema.docstring_text + + @property + def docstring_type(self) -> str: + if not self.schema: + return "None" + if self.nullable: + return f"{self.schema.docstring_type} or None" + return self.schema.docstring_type + @property def is_stream_response(self) -> bool: """Is the response expected to be streamable, like a download.""" return self.binary + @property + def is_exception(self) -> bool: + if self.schema: + return cast(ObjectSchema, self.schema).is_exception + return False + @classmethod def from_yaml(cls, yaml_data: Dict[str, Any]) -> "SchemaResponse": diff --git a/autorest/codegen/templates/config.py.jinja2 b/autorest/codegen/templates/config.py.jinja2 index 57a87a87a9f..b8b45964104 100644 --- a/autorest/codegen/templates/config.py.jinja2 +++ b/autorest/codegen/templates/config.py.jinja2 @@ -35,7 +35,7 @@ class {{ code_model.class_name }}Configuration(Configuration): {% endif %} {% for parameter in code_model.global_parameters.method %} :param {{ parameter.serialized_name }}: {{ parameter.description }} - :type {{ parameter.serialized_name }}: {{ parameter.schema.docstring_type }} + :type {{ parameter.serialized_name }}: {{ parameter.docstring_type }} {% endfor %} """ @@ -54,7 +54,7 @@ class {{ code_model.class_name }}Configuration(Configuration): {% endfor %} {% if code_model.global_parameters.constant %} {% for constant_parameter in code_model.global_parameters.constant %} - self.{{ constant_parameter.serialized_name }} = {{ constant_parameter.schema.get_declaration(constant_parameter.schema.value) }} + self.{{ constant_parameter.serialized_name }} = {{ constant_parameter.constant_declaration }} {% endfor %} {% endif %} {% if code_model.options['credential_scopes'] is not none %} diff --git a/autorest/codegen/templates/lro_operation.py.jinja2 b/autorest/codegen/templates/lro_operation.py.jinja2 index 9be6ac74e52..bcc05aafa6a 100644 --- a/autorest/codegen/templates/lro_operation.py.jinja2 +++ b/autorest/codegen/templates/lro_operation.py.jinja2 @@ -3,12 +3,12 @@ {% set trace_decorator = "@distributed_trace_async" if async_mode else "@distributed_trace" %} {% set operation_name = "begin_"+operation.python_name %} {% macro return_docstring(async_mode) %} -:return: An instance of {{ "Async" if async_mode }}LROPoller that returns either {{ operation.responses[0].schema.docstring_text if operation.responses[0].has_body else "None"}} or the result of cls(response) -:rtype: ~azure.core.polling.{{ "Async" if async_mode }}LROPoller[{{ operation.responses[0].schema.docstring_type if operation.responses[0].has_body else "None" }}]{% endmacro %} +:return: An instance of {{ "Async" if async_mode }}LROPoller that returns either {{ operation.responses[0].docstring_text }} or the result of cls(response) +:rtype: ~azure.core.polling.{{ "Async" if async_mode }}LROPoller[{{ operation.responses[0].docstring_type }}]{% endmacro %} {% macro response_headers(response) %} response_headers = { {% for response_header in response.headers %} - '{{ response_header.name }}': self._deserialize('{{ response_header.schema.serialization_type }}', response.headers.get('{{ response_header.name }}')), + '{{ response_header.name }}': self._deserialize('{{ response_header.serialization_type }}', response.headers.get('{{ response_header.name }}')), {% endfor %} } {% endmacro %} diff --git a/autorest/codegen/templates/lro_operation_helper.jinja2 b/autorest/codegen/templates/lro_operation_helper.jinja2 index d7d3b087dd6..a51c10d1b6f 100644 --- a/autorest/codegen/templates/lro_operation_helper.jinja2 +++ b/autorest/codegen/templates/lro_operation_helper.jinja2 @@ -18,7 +18,7 @@ {%- for doc_string in param_documentation_string(parameter).replace('\n', '\n ').split('\n') %} {{ doc_string | wordwrap(width=95, break_long_words=False, wrapstring='\n ')}} {% endfor %} -:type {{ parameter.serialized_name }}: {{ parameter.schema.docstring_type }} +:type {{ parameter.serialized_name }}: {{ parameter.docstring_type }} {% endfor %} :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. diff --git a/autorest/codegen/templates/lro_paging_operation.py.jinja2 b/autorest/codegen/templates/lro_paging_operation.py.jinja2 index dd65f969181..d0bc31a1146 100644 --- a/autorest/codegen/templates/lro_paging_operation.py.jinja2 +++ b/autorest/codegen/templates/lro_paging_operation.py.jinja2 @@ -5,8 +5,8 @@ {% set trace_decorator = "@distributed_trace_async" if async_mode else "@distributed_trace" %} {% set operation_name = "begin_"+operation.python_name %} {% macro return_docstring(async_mode) %} -:return: An instance of {{ "Async" if async_mode }}LROPoller that returns an iterator like instance of either {{ operation.responses[0].schema.docstring_text if operation.responses[0].has_body else "None"}} or the result of cls(response) -:rtype: ~azure.core.polling.{{ "Async" if async_mode }}LROPoller[~azure.core.{{ "async_" if async_mode else "" }}paging.{{ "Async" if async_mode }}ItemPaged[{{ operation.responses[0].schema.docstring_type if operation.responses[0].has_body else "None" }}]]{% endmacro %} +:return: An instance of {{ "Async" if async_mode }}LROPoller that returns an iterator like instance of either {{ operation.responses[0].docstring_text }} or the result of cls(response) +:rtype: ~azure.core.polling.{{ "Async" if async_mode }}LROPoller[~azure.core.{{ "async_" if async_mode else "" }}paging.{{ "Async" if async_mode }}ItemPaged[{{ operation.responses[0].docstring_type }}]]{% endmacro %} {% macro operation_docstring(async_mode) %} {{ lro_helper.operation_docstring_helper(operation, async_mode) }} {{ return_docstring(async_mode) }} diff --git a/autorest/codegen/templates/metadata.json.jinja2 b/autorest/codegen/templates/metadata.json.jinja2 index 6be1c073bf0..3d8b841a52a 100644 --- a/autorest/codegen/templates/metadata.json.jinja2 +++ b/autorest/codegen/templates/metadata.json.jinja2 @@ -19,7 +19,7 @@ {{ gp.serialized_name | tojson }}: { "method_signature": {{ gp.sync_method_signature | tojson }}, "description": {{ gp.description | tojson }}, - "docstring_type": {{ gp.schema.docstring_type | tojson }}, + "docstring_type": {{ gp.docstring_type | tojson }}, "required": {{ gp.required | tojson }} }{{ "," if not loop.last else "" }} {% endfor %} @@ -29,7 +29,7 @@ {{ gp.serialized_name | tojson }}: { "method_signature": {{ gp.sync_method_signature | tojson }}, "description": {{ gp.description | tojson }}, - "docstring_type": {{ gp.schema.docstring_type | tojson }}, + "docstring_type": {{ gp.docstring_type | tojson }}, "required": {{ gp.required | tojson }} }{{ "," if not loop.last else "" }} {% endfor %} @@ -37,7 +37,7 @@ "constant": { {% for gp in code_model.global_parameters.constant %} {% if gp.serialized_name != "api_version" %} - {{ gp.serialized_name | tojson }}: {{ gp.schema.get_declaration(gp.schema.value) | tojson }}{{ "," if not loop.last else "" }} + {{ gp.serialized_name | tojson }}: {{ gp.constant_declaration | tojson }}{{ "," if not loop.last else "" }} {% endif %} {% endfor %} }, diff --git a/autorest/codegen/templates/model.py.jinja2 b/autorest/codegen/templates/model.py.jinja2 index 337d7b0d7dd..eb7a156f3f5 100644 --- a/autorest/codegen/templates/model.py.jinja2 +++ b/autorest/codegen/templates/model.py.jinja2 @@ -43,8 +43,7 @@ class {{ model.name }}(msrest.serialization.Model): _attribute_map = { {% if model.properties != None %} {% for p in model.properties %} - {% set xml_metadata = (", 'xml': {" + p.schema.xml_serialization_ctxt() + "}") if p.schema.has_xml_serialization_ctxt else "" %} - '{{ p.name }}': {'key': '{{ p.escaped_swagger_name }}', 'type': '{{ p.schema.serialization_type}}'{{ xml_metadata }}}, + '{{ p.name }}': {'key': '{{ p.escaped_swagger_name }}', 'type': '{{ p.serialization_type}}'{{ p.xml_metadata }}}, {% endfor %} {% else%} {% endif %} @@ -63,7 +62,7 @@ class {{ model.name }}(msrest.serialization.Model): {% if (model.properties | selectattr('constant') | first) is defined %} {% for p in model.properties | selectattr('constant')%} - {{ p.name }} = {{ p.schema.get_declaration(p.schema.value) }} + {{ p.name }} = {{ p.constant_declaration }} {% endfor %} {% endif %} diff --git a/autorest/codegen/templates/operation.py.jinja2 b/autorest/codegen/templates/operation.py.jinja2 index b8006e11e2e..09240241772 100644 --- a/autorest/codegen/templates/operation.py.jinja2 +++ b/autorest/codegen/templates/operation.py.jinja2 @@ -11,8 +11,8 @@ :rtype: {{ return_type }} {%- else -%} {% 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.has_optional_return_type }} +:return: {{ operation.responses|selectattr('has_body')|map(attribute='docstring_text')|unique|join(' or ') }}, or the result of cls(response) +:rtype: {{ operation.responses|selectattr('has_body')| 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 @@ -39,7 +39,7 @@ {% endfor %} {% if (operation.requests | length) > 1 %} {% set content_type_constant = operation.parameters.constant|selectattr("implementation", "equalto", "Method")|selectattr("original_parameter", "equalto", None)|selectattr("in_method_code") | selectattr("serialized_name", "equalto", "content_type") | first %} -:keyword str content_type: Media type of the body sent to the API. Default value is {{ content_type_constant.schema.get_declaration(content_type_constant.schema.value) }}. +:keyword str content_type: Media type of the body sent to the API. Default value is {{ content_type_constant.constant_declaration }}. Allowed values are: "{{ operation.requests | map(attribute="media_types") | sum(start = []) | unique | list | join ('", "') }}". {% endif %} :keyword callable cls: A custom type or function that will be passed the direct response @@ -72,9 +72,9 @@ {% if operation.parameters.constant|selectattr("implementation", "equalto", "Method")|selectattr("original_parameter", "equalto", None)|selectattr("in_method_code") %} {% for constant_parameter in operation.parameters.constant|selectattr("implementation", "equalto", "Method")|selectattr("original_parameter", "equalto", None)|selectattr("in_method_code") %} {% if constant_parameter.serialized_name == "content_type" %} - content_type = kwargs.pop("content_type", {{ constant_parameter.schema.get_declaration(constant_parameter.schema.value) }}) + content_type = kwargs.pop("content_type", {{ constant_parameter.constant_declaration }}) {% else %} - {{ constant_parameter.serialized_name }} = {{ constant_parameter.schema.get_declaration(constant_parameter.schema.value) }} + {{ constant_parameter.serialized_name }} = {{ constant_parameter.constant_declaration }} {% endif %} {% endfor %} {% endif %} diff --git a/autorest/codegen/templates/operation_tools.jinja2 b/autorest/codegen/templates/operation_tools.jinja2 index ae2fd840864..305fc818d3c 100644 --- a/autorest/codegen/templates/operation_tools.jinja2 +++ b/autorest/codegen/templates/operation_tools.jinja2 @@ -2,9 +2,9 @@ {%- if return_type -%} {{ return_type }} {%- else -%} -{{ ((return_type_wrapper | join("[") + "[") 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 operation.has_optional_return_type else "") ~ ( ("]" * return_type_wrapper | count ) if return_type_wrapper else "") +{{ ((return_type_wrapper | join("[") + "[") if return_type_wrapper else "") ~ ("Optional[" if operation.has_optional_return_type else "" ) ~ ("Union[" if operation.responses | selectattr('has_body') | map(attribute='operation_type_annotation') | unique | list | length > 1 else "") ~ +(operation.responses | selectattr('has_body') | map(attribute='operation_type_annotation') | unique | join(', ')) ~ +("]" if operation.responses | selectattr('has_body') | map(attribute='operation_type_annotation')| unique | list | length > 1 else "") ~ ("]" if operation.has_optional_return_type else "") ~ ( ("]" * return_type_wrapper | count ) if return_type_wrapper else "") if operation.responses | selectattr('has_body') | first else ((return_type_wrapper | join("[") + "[") if return_type_wrapper else "") ~ ("Optional[" if operation.has_optional_return_type else "" ) ~ "None" ~ ("]" if operation.has_optional_return_type else "") ~ ( ("]" * return_type_wrapper | count ) if return_type_wrapper else "") }}{%- endif -%}{% endmacro %} {# get async mypy typing #} @@ -47,7 +47,7 @@ error_map = { {% endif %} {% for excep in operation.status_code_exceptions %} {% for status_code in excep.status_codes %} - {% set error_model = ", model=self._deserialize(models." + excep.schema.serialization_type + ", response)" if excep.schema.is_exception else "" %} + {% set error_model = ", model=self._deserialize(models." + excep.serialization_type + ", response)" if excep.is_exception else "" %} {% set error_format = ", error_format=ARMErrorFormat" if code_model.options['azure_arm'] else "" %} {% if status_code == 401 %} 401: lambda response: ClientAuthenticationError(response=response{{ error_model }}{{ error_format }}), @@ -74,13 +74,13 @@ error_map.update(kwargs.pop('error_map', {})){%- endmacro -%} {% macro response_handling(response) %} {% if response.headers %} {% for response_header in response.headers %} -response_headers['{{ response_header.name }}']=self._deserialize('{{ response_header.schema.serialization_type }}', response.headers.get('{{ response_header.name }}')) +response_headers['{{ response_header.name }}']=self._deserialize('{{ response_header.serialization_type }}', response.headers.get('{{ response_header.name }}')) {% endfor %} {% endif %} {% if response.is_stream_response %} deserialized = response.stream_download(self._client._pipeline) {% elif response.has_body %} -deserialized = self._deserialize('{{ response.schema.serialization_type }}', pipeline_response) +deserialized = self._deserialize('{{ response.serialization_type }}', pipeline_response) {% endif %} {% endmacro %} {# write grouped parameters #} @@ -130,15 +130,15 @@ if {{ header_parameter.full_serialized_name }} is not None: {% macro stream_body_params(operation) %}body_content_kwargs['stream_content'] = {{ operation.parameters.body[0].serialized_name }}{% endmacro %} {# helper for non-stream body params with schema #} {% macro non_stream_body_params(operation, send_xml, request_as_xml) %} -{% set ser_ctxt = operation.parameters.body[0].schema.xml_serialization_ctxt() if send_xml else None %} +{% set ser_ctxt = operation.parameters.body[0].xml_serialization_ctxt if send_xml else None %} {% if ser_ctxt %} serialization_ctxt = {'xml': {{ "{" }}{{ ser_ctxt }}{{ "}}" }} {% endif %} {% if operation.parameters.body[0].required %} -body_content = self._serialize.body({{ operation.parameters.body[0].serialized_name }}, '{{ operation.parameters.body[0].schema.serialization_type }}'{{ request_as_xml }}{{ ", serialization_ctxt=serialization_ctxt" if ser_ctxt else "" }}) +body_content = self._serialize.body({{ operation.parameters.body[0].serialized_name }}, '{{ operation.parameters.body[0].serialization_type }}'{{ request_as_xml }}{{ ", serialization_ctxt=serialization_ctxt" if ser_ctxt else "" }}) {% else %} if {{ operation.parameters.body[0].serialized_name }} is not None: - body_content = self._serialize.body({{ operation.parameters.body[0].serialized_name }}, '{{ operation.parameters.body[0].schema.serialization_type }}'{{ request_as_xml }}{{ ", serialization_ctxt=serialization_ctxt" if ser_ctxt else "" }}) + body_content = self._serialize.body({{ operation.parameters.body[0].serialized_name }}, '{{ operation.parameters.body[0].serialization_type }}'{{ request_as_xml }}{{ ", serialization_ctxt=serialization_ctxt" if ser_ctxt else "" }}) else: body_content = None {% endif %} diff --git a/autorest/codegen/templates/paging_operation.py.jinja2 b/autorest/codegen/templates/paging_operation.py.jinja2 index 8514bfc2943..6cced477f83 100644 --- a/autorest/codegen/templates/paging_operation.py.jinja2 +++ b/autorest/codegen/templates/paging_operation.py.jinja2 @@ -5,9 +5,9 @@ {% set item_paged = "AsyncItemPaged" if async_mode else "ItemPaged" %} {% macro return_docstring(async_mode) %} {% if operation.responses | selectattr('has_body') | first %} -:return: An iterator like instance of either {{ operation.responses|selectattr('has_body')|map(attribute='schema')|map(attribute='docstring_text')|unique|join(' or ') }} or the result of cls(response) +:return: An iterator like instance of either {{ operation.responses|selectattr('has_body')|map(attribute='docstring_text')|unique|join(' or ') }} or the result of cls(response) {# can't use item_paged variable, otherwise the call to get docstring from the metadata template will always return ItemPaged #} -:rtype: ~azure.core.{{ "async_" if async_mode else "" }}paging.{{ "Async" if async_mode }}ItemPaged[{% for response in operation.responses %}{{response.schema.docstring_type if response.has_body else "None"}}{% if not loop.last -%} or {% endif %}{% endfor %}] +:rtype: ~azure.core.{{ "async_" if async_mode else "" }}paging.{{ "Async" if async_mode }}ItemPaged[{% for response in operation.responses %}{{response.docstring_type if response.has_body else "None"}}{% if not loop.last -%} or {% endif %}{% endfor %}] {%- else -%} :return: None :rtype: None{%- endif -%}{%- endmacro -%} @@ -27,7 +27,7 @@ {%- for doc_string in param_documentation_string(parameter).replace('\n', '\n ').split('\n') %} {{ doc_string | wordwrap(width=95, break_long_words=False, wrapstring='\n ')}} {% endfor %} -:type {{ parameter.serialized_name }}: {{ parameter.schema.docstring_type }} +:type {{ parameter.serialized_name }}: {{ parameter.docstring_type }} {% endfor %} :keyword callable cls: A custom type or function that will be passed the direct response {{ return_docstring(async_mode) }} diff --git a/autorest/codegen/templates/paging_operation_helper.jinja2 b/autorest/codegen/templates/paging_operation_helper.jinja2 index fe318dd8232..63a592262c0 100644 --- a/autorest/codegen/templates/paging_operation_helper.jinja2 +++ b/autorest/codegen/templates/paging_operation_helper.jinja2 @@ -13,7 +13,7 @@ cls = kwargs.pop('cls', None) # type: ClsType[{{ op_tools.return_type_annotatio {% endif %} {% if operation.parameters.constant|selectattr("implementation", "equalto", "Method") %} {% for constant_parameter in operation.parameters.constant|selectattr("implementation", "equalto", "Method") %} - {{ constant_parameter.serialized_name }} = {{ constant_parameter.schema.get_declaration(constant_parameter.schema.value) }} + {{ constant_parameter.serialized_name }} = {{ constant_parameter.constant_declaration }} {% endfor %} {% endif %} @@ -62,7 +62,7 @@ cls = kwargs.pop('cls', None) # type: ClsType[{{ op_tools.return_type_annotatio {{ keywords.def }} extract_data(pipeline_response): {% set response = operation.responses[0] %} - deserialized = self._deserialize('{{ response.schema.serialization_type }}', pipeline_response) + deserialized = self._deserialize('{{ response.serialization_type }}', pipeline_response) list_of_elem = deserialized.{{ operation.item_name }} if cls: list_of_elem = cls(list_of_elem) diff --git a/autorest/codegen/templates/service_client.py.jinja2 b/autorest/codegen/templates/service_client.py.jinja2 index 2b2e27ae3cf..a11734a9bf0 100644 --- a/autorest/codegen/templates/service_client.py.jinja2 +++ b/autorest/codegen/templates/service_client.py.jinja2 @@ -53,7 +53,7 @@ class {{ code_model.class_name }}({{ base_class }}): {% endfor %} {% for parameter in code_model.global_parameters.method %} :param {{ parameter.serialized_name }}: {{ parameter.description }} - :type {{ parameter.serialized_name }}: {{ parameter.schema.docstring_type }} + :type {{ parameter.serialized_name }}: {{ parameter.docstring_type }} {% endfor %} {% if not code_model.custom_base_url %} :param str base_url: Service URL diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/_duration_operations.py b/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/_duration_operations.py index ac6d7e3e4a4..c34fbbb55d3 100644 --- a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/_duration_operations.py +++ b/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/aio/operations/_duration_operations.py @@ -45,15 +45,15 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_null( self, **kwargs - ) -> datetime.timedelta: + ) -> Optional[datetime.timedelta]: """Get null duration value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: timedelta, or the result of cls(response) - :rtype: ~datetime.timedelta + :return: timedelta or None, or the result of cls(response) + :rtype: ~datetime.timedelta or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[datetime.timedelta] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.timedelta]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py b/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py index 06a0b8b5c55..ba3a5bd93c2 100644 --- a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py +++ b/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py @@ -50,15 +50,15 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> datetime.timedelta + # type: (...) -> Optional[datetime.timedelta] """Get null duration value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: timedelta, or the result of cls(response) - :rtype: ~datetime.timedelta + :return: timedelta or None, or the result of cls(response) + :rtype: ~datetime.timedelta or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[datetime.timedelta] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.timedelta]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/_bool_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/_bool_operations.py index 6d383bb6a00..e8787e26edb 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/_bool_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/aio/operations/_bool_operations.py @@ -234,15 +234,15 @@ async def put_false( async def get_null( self, **kwargs - ) -> bool: + ) -> Optional[bool]: """Get null Boolean value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool + :return: bool or None, or the result of cls(response) + :rtype: bool or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[bool] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[bool]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/_bool_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/_bool_operations.py index f24b5b0297b..841519490b1 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/_bool_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/_bool_operations.py @@ -243,15 +243,15 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> bool + # type: (...) -> Optional[bool] """Get null Boolean value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: bool, or the result of cls(response) - :rtype: bool + :return: bool or None, or the result of cls(response) + :rtype: bool or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[bool] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[bool]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/_date_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/_date_operations.py index bedd3a9e1fd..1b9ad1b206b 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/_date_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/aio/operations/_date_operations.py @@ -45,15 +45,15 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_null( self, **kwargs - ) -> datetime.date: + ) -> Optional[datetime.date]: """Get null date value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: date, or the result of cls(response) - :rtype: ~datetime.date + :return: date or None, or the result of cls(response) + :rtype: ~datetime.date or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[datetime.date] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.date]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/operations/_date_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/operations/_date_operations.py index 1c7c6b6ab0b..16040be60be 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/operations/_date_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/operations/_date_operations.py @@ -50,15 +50,15 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> datetime.date + # type: (...) -> Optional[datetime.date] """Get null date value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: date, or the result of cls(response) - :rtype: ~datetime.date + :return: date or None, or the result of cls(response) + :rtype: ~datetime.date or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[datetime.date] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.date]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/_datetime_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/_datetime_operations.py index 809d5367cbb..485660616ac 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/_datetime_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/aio/operations/_datetime_operations.py @@ -45,15 +45,15 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_null( self, **kwargs - ) -> datetime.datetime: + ) -> Optional[datetime.datetime]: """Get null datetime value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime + :return: datetime or None, or the result of cls(response) + :rtype: ~datetime.datetime or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[datetime.datetime] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.datetime]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/_datetime_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/_datetime_operations.py index 038d443bcab..e31a2dfc264 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/_datetime_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/_datetime_operations.py @@ -50,15 +50,15 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> datetime.datetime + # type: (...) -> Optional[datetime.datetime] """Get null datetime value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime + :return: datetime or None, or the result of cls(response) + :rtype: ~datetime.datetime or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[datetime.datetime] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.datetime]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/_datetimerfc1123_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/_datetimerfc1123_operations.py index 9cae5997fc5..7541fdcd221 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/_datetimerfc1123_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/aio/operations/_datetimerfc1123_operations.py @@ -45,15 +45,15 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_null( self, **kwargs - ) -> datetime.datetime: + ) -> Optional[datetime.datetime]: """Get null datetime value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime + :return: datetime or None, or the result of cls(response) + :rtype: ~datetime.datetime or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[datetime.datetime] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.datetime]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/_datetimerfc1123_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/_datetimerfc1123_operations.py index 09357977cd3..29c511ad193 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/_datetimerfc1123_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/_datetimerfc1123_operations.py @@ -50,15 +50,15 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> datetime.datetime + # type: (...) -> Optional[datetime.datetime] """Get null datetime value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime + :return: datetime or None, or the result of cls(response) + :rtype: ~datetime.datetime or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[datetime.datetime] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.datetime]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/_duration_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/_duration_operations.py index ac6d7e3e4a4..c34fbbb55d3 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/_duration_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/aio/operations/_duration_operations.py @@ -45,15 +45,15 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_null( self, **kwargs - ) -> datetime.timedelta: + ) -> Optional[datetime.timedelta]: """Get null duration value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: timedelta, or the result of cls(response) - :rtype: ~datetime.timedelta + :return: timedelta or None, or the result of cls(response) + :rtype: ~datetime.timedelta or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[datetime.timedelta] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.timedelta]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/_duration_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/_duration_operations.py index 06a0b8b5c55..ba3a5bd93c2 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/_duration_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/_duration_operations.py @@ -50,15 +50,15 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> datetime.timedelta + # type: (...) -> Optional[datetime.timedelta] """Get null duration value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: timedelta, or the result of cls(response) - :rtype: ~datetime.timedelta + :return: timedelta or None, or the result of cls(response) + :rtype: ~datetime.timedelta or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[datetime.timedelta] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.timedelta]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/_int_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/_int_operations.py index 029d1ff412a..65a59bc0c12 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/_int_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/aio/operations/_int_operations.py @@ -45,15 +45,15 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_null( self, **kwargs - ) -> int: + ) -> Optional[int]: """Get null Int value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: int, or the result of cls(response) - :rtype: int + :return: int or None, or the result of cls(response) + :rtype: int or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[int] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[int]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -668,15 +668,15 @@ async def get_invalid_unix_time( async def get_null_unix_time( self, **kwargs - ) -> datetime.datetime: + ) -> Optional[datetime.datetime]: """Get null Unix time value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime + :return: datetime or None, or the result of cls(response) + :rtype: ~datetime.datetime or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[datetime.datetime] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.datetime]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/_int_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/_int_operations.py index a173b3e3a85..5e36a2036d2 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/_int_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/_int_operations.py @@ -50,15 +50,15 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> int + # type: (...) -> Optional[int] """Get null Int value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: int, or the result of cls(response) - :rtype: int + :return: int or None, or the result of cls(response) + :rtype: int or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[int] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[int]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -686,15 +686,15 @@ def get_null_unix_time( self, **kwargs # type: Any ): - # type: (...) -> datetime.datetime + # type: (...) -> Optional[datetime.datetime] """Get null Unix time value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: datetime, or the result of cls(response) - :rtype: ~datetime.datetime + :return: datetime or None, or the result of cls(response) + :rtype: ~datetime.datetime or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[datetime.datetime] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.datetime]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/_number_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/_number_operations.py index 920d5975242..426e3c7d23e 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/_number_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/aio/operations/_number_operations.py @@ -44,15 +44,15 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_null( self, **kwargs - ) -> float: + ) -> Optional[float]: """Get null Number value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float + :return: float or None, or the result of cls(response) + :rtype: float or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[float] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[float]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/_number_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/_number_operations.py index 66d36dea7d6..21f4b629777 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/_number_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/_number_operations.py @@ -49,15 +49,15 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> float + # type: (...) -> Optional[float] """Get null Number value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: float, or the result of cls(response) - :rtype: float + :return: float or None, or the result of cls(response) + :rtype: float or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[float] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[float]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_string_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_string_operations.py index 95b0b5531d6..f79b8888072 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_string_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/aio/operations/_string_operations.py @@ -44,15 +44,15 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_null( self, **kwargs - ) -> str: + ) -> Optional[str]: """Get null string value value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str + :return: str or None, or the result of cls(response) + :rtype: str or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[str]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -622,15 +622,15 @@ async def put_base64_url_encoded( async def get_null_base64_url_encoded( self, **kwargs - ) -> bytes: + ) -> Optional[bytes]: """Get null value that is expected to be base64url encoded. :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytes, or the result of cls(response) - :rtype: bytes + :return: bytes or None, or the result of cls(response) + :rtype: bytes or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[bytes] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[bytes]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/operations/_string_operations.py b/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/operations/_string_operations.py index d6036a31837..236d2c69754 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/operations/_string_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/operations/_string_operations.py @@ -49,15 +49,15 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> str + # type: (...) -> Optional[str] """Get null string value value. :keyword callable cls: A custom type or function that will be passed the direct response - :return: str, or the result of cls(response) - :rtype: str + :return: str or None, or the result of cls(response) + :rtype: str or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[str] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[str]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -639,15 +639,15 @@ def get_null_base64_url_encoded( self, **kwargs # type: Any ): - # type: (...) -> bytes + # type: (...) -> Optional[bytes] """Get null value that is expected to be base64url encoded. :keyword callable cls: A custom type or function that will be passed the direct response - :return: bytes, or the result of cls(response) - :rtype: bytes + :return: bytes or None, or the result of cls(response) + :rtype: bytes or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[bytes] + cls = kwargs.pop('cls', None) # type: ClsType[Optional[bytes]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError }