diff --git a/autorest/codegen/models/dictionary_schema.py b/autorest/codegen/models/dictionary_schema.py index ae56f7062e0..51bf8a7e994 100644 --- a/autorest/codegen/models/dictionary_schema.py +++ b/autorest/codegen/models/dictionary_schema.py @@ -3,7 +3,7 @@ # Licensed under the MIT License. See License.txt in the project root for # license information. # -------------------------------------------------------------------------- -from typing import Any, Dict, Optional, Union +from typing import Any, Dict, Optional from .base_schema import BaseSchema from .imports import FileImport, ImportType, TypingSection @@ -25,7 +25,6 @@ def __init__( ) -> None: super(DictionarySchema, self).__init__(namespace=namespace, yaml_data=yaml_data) self.element_type = element_type - self.nullable_items = self.yaml_data.get("nullableItems", False) @property def serialization_type(self) -> str: @@ -61,13 +60,6 @@ def docstring_type(self) -> str: """ return f"dict[str, {self.element_type.docstring_type}]" - @property - def validation_map(self) -> Optional[Dict[str, Union[bool, int, str]]]: - validation_map: Dict[str, Union[bool, int, str]] = {} - if self.nullable_items: - validation_map["nullable_items"] = True - return validation_map or None - def xml_serialization_ctxt(self) -> Optional[str]: raise NotImplementedError("Dictionary schema does not support XML serialization.") diff --git a/autorest/codegen/models/list_schema.py b/autorest/codegen/models/list_schema.py index a9731332bc6..97c589cd885 100644 --- a/autorest/codegen/models/list_schema.py +++ b/autorest/codegen/models/list_schema.py @@ -14,14 +14,16 @@ def __init__( namespace: str, yaml_data: Dict[str, Any], element_type: BaseSchema, + *, + max_items: Optional[int] = None, + min_items: Optional[int] = None, + unique_items: Optional[int] = None, ) -> None: super(ListSchema, self).__init__(namespace=namespace, yaml_data=yaml_data) self.element_type = element_type - - self.max_items = self.yaml_data.get("maxItems", False) - self.min_items = self.yaml_data.get("minItems", False) - self.unique_items = self.yaml_data.get("uniqueItems", False) - self.nullable_items = self.yaml_data.get("nullableItems", False) + self.max_items = max_items + self.min_items = min_items + self.unique_items = unique_items @property def serialization_type(self) -> str: @@ -53,8 +55,6 @@ def validation_map(self) -> Optional[Dict[str, Union[bool, int, str]]]: validation_map["min_items"] = self.min_items if self.unique_items: validation_map["unique"] = True - if self.nullable_items: - validation_map["nullable_items"] = True return validation_map or None @property @@ -94,7 +94,10 @@ def from_yaml(cls, namespace: str, yaml_data: Dict[str, Any], **kwargs) -> "List return cls( namespace=namespace, yaml_data=yaml_data, - element_type=element_type + element_type=element_type, + max_items=yaml_data.get("maxItems"), + min_items=yaml_data.get("minItems"), + unique_items=yaml_data.get("uniqueItems"), ) def imports(self) -> FileImport: diff --git a/autorest/codegen/models/property.py b/autorest/codegen/models/property.py index e9fe4359552..bc2b57db020 100644 --- a/autorest/codegen/models/property.py +++ b/autorest/codegen/models/property.py @@ -46,9 +46,6 @@ def __init__( validation_map["readonly"] = True if self.constant: validation_map["constant"] = True - if self.yaml_data.get("nullable", False): - validation_map["nullable"] = True - if self.schema.validation_map: validation_map_from_schema = cast(Dict[str, Union[bool, int, str]], self.schema.validation_map) validation_map.update(validation_map_from_schema) diff --git a/autorest/codegen/models/schema_response.py b/autorest/codegen/models/schema_response.py index e46d076e1ef..bb549711781 100644 --- a/autorest/codegen/models/schema_response.py +++ b/autorest/codegen/models/schema_response.py @@ -31,15 +31,6 @@ def __init__( self.status_codes = status_codes self.headers = headers self.binary = binary - self.nullable = self.yaml_data.get("nullable", False) - - @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 has_body(self) -> bool: diff --git a/autorest/codegen/templates/operation_tools.jinja2 b/autorest/codegen/templates/operation_tools.jinja2 index 3f820180b2b..ae2fd840864 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='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 "") +{{ ((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 "") 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 #} diff --git a/package.json b/package.json index 88ac91976c3..d750cdbccb6 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,7 @@ }, "devDependencies": { "@autorest/autorest": "^3.0.0", - "@microsoft.azure/autorest.testserver": "^2.10.58" + "@microsoft.azure/autorest.testserver": "^2.10.56" }, "files": [ "autorest/**/*.py", 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 9308c8720c1..ac6d7e3e4a4 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,7 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_null( self, **kwargs - ) -> Optional[datetime.timedelta]: + ) -> datetime.timedelta: """Get null duration value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -53,7 +53,7 @@ async def get_null( :rtype: ~datetime.timedelta :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.timedelta]] + cls = kwargs.pop('cls', None) # type: ClsType[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 18f08481a09..06a0b8b5c55 100644 --- a/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py +++ b/test/azure/Expected/AcceptanceTests/AzureBodyDuration/bodyduration/operations/_duration_operations.py @@ -50,7 +50,7 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> Optional[datetime.timedelta] + # type: (...) -> datetime.timedelta """Get null duration value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,7 +58,7 @@ def get_null( :rtype: ~datetime.timedelta :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.timedelta]] + cls = kwargs.pop('cls', None) # type: ClsType[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 2b18c282ad5..6d383bb6a00 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,7 +234,7 @@ async def put_false( async def get_null( self, **kwargs - ) -> Optional[bool]: + ) -> bool: """Get null Boolean value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -242,7 +242,7 @@ async def get_null( :rtype: bool :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[bool]] + cls = kwargs.pop('cls', None) # type: ClsType[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 1183efa6487..f24b5b0297b 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/_bool_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyBoolean/bodyboolean/operations/_bool_operations.py @@ -243,7 +243,7 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> Optional[bool] + # type: (...) -> bool """Get null Boolean value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -251,7 +251,7 @@ def get_null( :rtype: bool :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[bool]] + cls = kwargs.pop('cls', None) # type: ClsType[bool] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models.py index 5fde6c51aa0..fb442f4c09a 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models.py @@ -41,10 +41,6 @@ class Basic(msrest.serialization.Model): :type color: str or ~bodycomplex.models.CMYKColors """ - _validation = { - 'id': {'nullable': True}, - } - _attribute_map = { 'id': {'key': 'id', 'type': 'int'}, 'name': {'key': 'name', 'type': 'str'}, @@ -369,10 +365,6 @@ class DictionaryWrapper(msrest.serialization.Model): :type default_program: dict[str, str] """ - _validation = { - 'default_program': {'nullable': True}, - } - _attribute_map = { 'default_program': {'key': 'defaultProgram', 'type': '{str}'}, } diff --git a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models_py3.py b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models_py3.py index 90d6e094900..c51b318ac50 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models_py3.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyComplex/bodycomplex/models/_models_py3.py @@ -48,10 +48,6 @@ class Basic(msrest.serialization.Model): :type color: str or ~bodycomplex.models.CMYKColors """ - _validation = { - 'id': {'nullable': True}, - } - _attribute_map = { 'id': {'key': 'id', 'type': 'int'}, 'name': {'key': 'name', 'type': 'str'}, @@ -418,10 +414,6 @@ class DictionaryWrapper(msrest.serialization.Model): :type default_program: dict[str, str] """ - _validation = { - 'default_program': {'nullable': True}, - } - _attribute_map = { 'default_program': {'key': 'defaultProgram', 'type': '{str}'}, } 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 ce947649dea..bedd3a9e1fd 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,7 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_null( self, **kwargs - ) -> Optional[datetime.date]: + ) -> datetime.date: """Get null date value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -53,7 +53,7 @@ async def get_null( :rtype: ~datetime.date :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.date]] + cls = kwargs.pop('cls', None) # type: ClsType[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 e17317b2c1e..1c7c6b6ab0b 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/operations/_date_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyDate/bodydate/operations/_date_operations.py @@ -50,7 +50,7 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> Optional[datetime.date] + # type: (...) -> datetime.date """Get null date value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,7 +58,7 @@ def get_null( :rtype: ~datetime.date :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.date]] + cls = kwargs.pop('cls', None) # type: ClsType[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 15b879eadbd..809d5367cbb 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,7 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_null( self, **kwargs - ) -> Optional[datetime.datetime]: + ) -> datetime.datetime: """Get null datetime value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -53,7 +53,7 @@ async def get_null( :rtype: ~datetime.datetime :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.datetime]] + cls = kwargs.pop('cls', None) # type: ClsType[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 9411a966cab..038d443bcab 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/_datetime_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyDateTime/bodydatetime/operations/_datetime_operations.py @@ -50,7 +50,7 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> Optional[datetime.datetime] + # type: (...) -> datetime.datetime """Get null datetime value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,7 +58,7 @@ def get_null( :rtype: ~datetime.datetime :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.datetime]] + cls = kwargs.pop('cls', None) # type: ClsType[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 ab26789d965..9cae5997fc5 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,7 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_null( self, **kwargs - ) -> Optional[datetime.datetime]: + ) -> datetime.datetime: """Get null datetime value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -53,7 +53,7 @@ async def get_null( :rtype: ~datetime.datetime :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.datetime]] + cls = kwargs.pop('cls', None) # type: ClsType[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 2cd6ddc139c..09357977cd3 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/_datetimerfc1123_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyDateTimeRfc1123/bodydatetimerfc1123/operations/_datetimerfc1123_operations.py @@ -50,7 +50,7 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> Optional[datetime.datetime] + # type: (...) -> datetime.datetime """Get null datetime value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,7 +58,7 @@ def get_null( :rtype: ~datetime.datetime :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.datetime]] + cls = kwargs.pop('cls', None) # type: ClsType[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 9308c8720c1..ac6d7e3e4a4 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,7 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_null( self, **kwargs - ) -> Optional[datetime.timedelta]: + ) -> datetime.timedelta: """Get null duration value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -53,7 +53,7 @@ async def get_null( :rtype: ~datetime.timedelta :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.timedelta]] + cls = kwargs.pop('cls', None) # type: ClsType[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 18f08481a09..06a0b8b5c55 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/_duration_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyDuration/bodyduration/operations/_duration_operations.py @@ -50,7 +50,7 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> Optional[datetime.timedelta] + # type: (...) -> datetime.timedelta """Get null duration value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,7 +58,7 @@ def get_null( :rtype: ~datetime.timedelta :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.timedelta]] + cls = kwargs.pop('cls', None) # type: ClsType[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 caf675c8e65..029d1ff412a 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,7 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_null( self, **kwargs - ) -> Optional[int]: + ) -> int: """Get null Int value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -53,7 +53,7 @@ async def get_null( :rtype: int :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[int]] + cls = kwargs.pop('cls', None) # type: ClsType[int] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -668,7 +668,7 @@ async def get_invalid_unix_time( async def get_null_unix_time( self, **kwargs - ) -> Optional[datetime.datetime]: + ) -> datetime.datetime: """Get null Unix time value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -676,7 +676,7 @@ async def get_null_unix_time( :rtype: ~datetime.datetime :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.datetime]] + cls = kwargs.pop('cls', None) # type: ClsType[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 9c2578d7113..a173b3e3a85 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/_int_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyInteger/bodyinteger/operations/_int_operations.py @@ -50,7 +50,7 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> Optional[int] + # type: (...) -> int """Get null Int value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -58,7 +58,7 @@ def get_null( :rtype: int :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[int]] + cls = kwargs.pop('cls', None) # type: ClsType[int] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -686,7 +686,7 @@ def get_null_unix_time( self, **kwargs # type: Any ): - # type: (...) -> Optional[datetime.datetime] + # type: (...) -> datetime.datetime """Get null Unix time value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -694,7 +694,7 @@ def get_null_unix_time( :rtype: ~datetime.datetime :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[datetime.datetime]] + cls = kwargs.pop('cls', None) # type: ClsType[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 e9a3cd10c29..920d5975242 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,7 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_null( self, **kwargs - ) -> Optional[float]: + ) -> float: """Get null Number value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -52,7 +52,7 @@ async def get_null( :rtype: float :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[float]] + cls = kwargs.pop('cls', None) # type: ClsType[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 2c8d7818fd8..66d36dea7d6 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/_number_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyNumber/bodynumber/operations/_number_operations.py @@ -49,7 +49,7 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> Optional[float] + # type: (...) -> float """Get null Number value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -57,7 +57,7 @@ def get_null( :rtype: float :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[float]] + cls = kwargs.pop('cls', None) # type: ClsType[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 bd5949e72ef..95b0b5531d6 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,7 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: async def get_null( self, **kwargs - ) -> Optional[str]: + ) -> str: """Get null string value value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -52,7 +52,7 @@ async def get_null( :rtype: str :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[str]] + cls = kwargs.pop('cls', None) # type: ClsType[str] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -622,7 +622,7 @@ async def put_base64_url_encoded( async def get_null_base64_url_encoded( self, **kwargs - ) -> Optional[bytes]: + ) -> 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 @@ -630,7 +630,7 @@ async def get_null_base64_url_encoded( :rtype: bytes :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[bytes]] + cls = kwargs.pop('cls', None) # type: ClsType[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 71dc455af64..d6036a31837 100644 --- a/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/operations/_string_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/BodyString/bodystring/operations/_string_operations.py @@ -49,7 +49,7 @@ def get_null( self, **kwargs # type: Any ): - # type: (...) -> Optional[str] + # type: (...) -> str """Get null string value value. :keyword callable cls: A custom type or function that will be passed the direct response @@ -57,7 +57,7 @@ def get_null( :rtype: str :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[str]] + cls = kwargs.pop('cls', None) # type: ClsType[str] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } @@ -639,7 +639,7 @@ def get_null_base64_url_encoded( self, **kwargs # type: Any ): - # type: (...) -> Optional[bytes] + # type: (...) -> 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 @@ -647,7 +647,7 @@ def get_null_base64_url_encoded( :rtype: bytes :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional[bytes]] + cls = kwargs.pop('cls', None) # type: ClsType[bytes] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError }