Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---
Return empty list instead of None for non-optional unwrapped XML list fields during deserialization
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: internal
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

Add unit test for deserializing Azure Blob Storage EnumerationResults XML payload with attributes, empty list element, and empty string element.
2 changes: 1 addition & 1 deletion packages/autorest.python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
"dependencies": {
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTk1Mzk0MS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.27.2.tgz",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTk1ODQ0MC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.27.2.tgz",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "^4.21.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/typespec-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"js-yaml": "~4.1.0",
"semver": "~7.6.2",
"tsx": "^4.21.0",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTk1Mzk0MS9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.27.2.tgz",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNTk1ODQ0MC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.27.2.tgz",
"fs-extra": "~11.2.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
if len(items) > 0:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = _deserialize(rf._type, items)
elif not rf._is_optional:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = []
continue

# text element is primitive type
Expand Down Expand Up @@ -891,6 +894,8 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
# is it optional?
try:
if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
if rf:
rf._is_optional = True
if len(annotation.__args__) <= 2: # pyright: ignore
if_obj_deserializer = _get_deserialize_callable_from_annotation(
next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
Expand Down Expand Up @@ -1049,6 +1054,7 @@ def _failsafe_deserialize_xml(
return None


# pylint: disable=too-many-instance-attributes
class _RestField:
def __init__(
self,
Expand All @@ -1068,6 +1074,7 @@ def __init__(
self._is_discriminator = is_discriminator
self._visibility = visibility
self._is_model = False
self._is_optional = False
self._default = default
self._format = format
self._is_multipart_file_input = is_multipart_file_input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
if len(items) > 0:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = _deserialize(rf._type, items)
elif not rf._is_optional:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = []
continue

# text element is primitive type
Expand Down Expand Up @@ -891,6 +894,8 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
# is it optional?
try:
if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
if rf:
rf._is_optional = True
if len(annotation.__args__) <= 2: # pyright: ignore
if_obj_deserializer = _get_deserialize_callable_from_annotation(
next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
Expand Down Expand Up @@ -1049,6 +1054,7 @@ def _failsafe_deserialize_xml(
return None


# pylint: disable=too-many-instance-attributes
class _RestField:
def __init__(
self,
Expand All @@ -1068,6 +1074,7 @@ def __init__(
self._is_discriminator = is_discriminator
self._visibility = visibility
self._is_model = False
self._is_optional = False
self._default = default
self._format = format
self._is_multipart_file_input = is_multipart_file_input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
if len(items) > 0:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = _deserialize(rf._type, items)
elif not rf._is_optional:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = []
continue

# text element is primitive type
Expand Down Expand Up @@ -891,6 +894,8 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
# is it optional?
try:
if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
if rf:
rf._is_optional = True
if len(annotation.__args__) <= 2: # pyright: ignore
if_obj_deserializer = _get_deserialize_callable_from_annotation(
next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
Expand Down Expand Up @@ -1049,6 +1054,7 @@ def _failsafe_deserialize_xml(
return None


# pylint: disable=too-many-instance-attributes
class _RestField:
def __init__(
self,
Expand All @@ -1068,6 +1074,7 @@ def __init__(
self._is_discriminator = is_discriminator
self._visibility = visibility
self._is_model = False
self._is_optional = False
self._default = default
self._format = format
self._is_multipart_file_input = is_multipart_file_input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
if len(items) > 0:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = _deserialize(rf._type, items)
elif not rf._is_optional:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = []
continue

# text element is primitive type
Expand Down Expand Up @@ -891,6 +894,8 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
# is it optional?
try:
if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
if rf:
rf._is_optional = True
if len(annotation.__args__) <= 2: # pyright: ignore
if_obj_deserializer = _get_deserialize_callable_from_annotation(
next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
Expand Down Expand Up @@ -1049,6 +1054,7 @@ def _failsafe_deserialize_xml(
return None


# pylint: disable=too-many-instance-attributes
class _RestField:
def __init__(
self,
Expand All @@ -1068,6 +1074,7 @@ def __init__(
self._is_discriminator = is_discriminator
self._visibility = visibility
self._is_model = False
self._is_optional = False
self._default = default
self._format = format
self._is_multipart_file_input = is_multipart_file_input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
if len(items) > 0:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = _deserialize(rf._type, items)
elif not rf._is_optional:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = []
continue

# text element is primitive type
Expand Down Expand Up @@ -891,6 +894,8 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
# is it optional?
try:
if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
if rf:
rf._is_optional = True
if len(annotation.__args__) <= 2: # pyright: ignore
if_obj_deserializer = _get_deserialize_callable_from_annotation(
next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
Expand Down Expand Up @@ -1049,6 +1054,7 @@ def _failsafe_deserialize_xml(
return None


# pylint: disable=too-many-instance-attributes
class _RestField:
def __init__(
self,
Expand All @@ -1068,6 +1074,7 @@ def __init__(
self._is_discriminator = is_discriminator
self._visibility = visibility
self._is_model = False
self._is_optional = False
self._default = default
self._format = format
self._is_multipart_file_input = is_multipart_file_input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
if len(items) > 0:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = _deserialize(rf._type, items)
elif not rf._is_optional:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = []
continue

# text element is primitive type
Expand Down Expand Up @@ -891,6 +894,8 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
# is it optional?
try:
if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
if rf:
rf._is_optional = True
if len(annotation.__args__) <= 2: # pyright: ignore
if_obj_deserializer = _get_deserialize_callable_from_annotation(
next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
Expand Down Expand Up @@ -1049,6 +1054,7 @@ def _failsafe_deserialize_xml(
return None


# pylint: disable=too-many-instance-attributes
class _RestField:
def __init__(
self,
Expand All @@ -1068,6 +1074,7 @@ def __init__(
self._is_discriminator = is_discriminator
self._visibility = visibility
self._is_model = False
self._is_optional = False
self._default = default
self._format = format
self._is_multipart_file_input = is_multipart_file_input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,9 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
if len(items) > 0:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = _deserialize(rf._type, items)
elif not rf._is_optional:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = []
continue

# text element is primitive type
Expand Down Expand Up @@ -905,6 +908,8 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
# is it optional?
try:
if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
if rf:
rf._is_optional = True
if len(annotation.__args__) <= 2: # pyright: ignore
if_obj_deserializer = _get_deserialize_callable_from_annotation(
next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
Expand Down Expand Up @@ -1063,6 +1068,7 @@ def _failsafe_deserialize_xml(
return None


# pylint: disable=too-many-instance-attributes
class _RestField:
def __init__(
self,
Expand All @@ -1082,6 +1088,7 @@ def __init__(
self._is_discriminator = is_discriminator
self._visibility = visibility
self._is_model = False
self._is_optional = False
self._default = default
self._format = format
self._is_multipart_file_input = is_multipart_file_input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
if len(items) > 0:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = _deserialize(rf._type, items)
elif not rf._is_optional:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = []
continue

# text element is primitive type
Expand Down Expand Up @@ -891,6 +894,8 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
# is it optional?
try:
if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
if rf:
rf._is_optional = True
if len(annotation.__args__) <= 2: # pyright: ignore
if_obj_deserializer = _get_deserialize_callable_from_annotation(
next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
Expand Down Expand Up @@ -1049,6 +1054,7 @@ def _failsafe_deserialize_xml(
return None


# pylint: disable=too-many-instance-attributes
class _RestField:
def __init__(
self,
Expand All @@ -1068,6 +1074,7 @@ def __init__(
self._is_discriminator = is_discriminator
self._visibility = visibility
self._is_model = False
self._is_optional = False
self._default = default
self._format = format
self._is_multipart_file_input = is_multipart_file_input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
if len(items) > 0:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = _deserialize(rf._type, items)
elif not rf._is_optional:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = []
continue

# text element is primitive type
Expand Down Expand Up @@ -891,6 +894,8 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
# is it optional?
try:
if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
if rf:
rf._is_optional = True
if len(annotation.__args__) <= 2: # pyright: ignore
if_obj_deserializer = _get_deserialize_callable_from_annotation(
next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
Expand Down Expand Up @@ -1049,6 +1054,7 @@ def _failsafe_deserialize_xml(
return None


# pylint: disable=too-many-instance-attributes
class _RestField:
def __init__(
self,
Expand All @@ -1068,6 +1074,7 @@ def __init__(
self._is_discriminator = is_discriminator
self._visibility = visibility
self._is_model = False
self._is_optional = False
self._default = default
self._format = format
self._is_multipart_file_input = is_multipart_file_input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,9 @@ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
if len(items) > 0:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = _deserialize(rf._type, items)
elif not rf._is_optional:
existed_attr_keys.append(xml_name)
dict_to_pass[rf._rest_name] = []
continue

# text element is primitive type
Expand Down Expand Up @@ -891,6 +894,8 @@ def _get_deserialize_callable_from_annotation( # pylint: disable=too-many-retur
# is it optional?
try:
if any(a is _NONE_TYPE for a in annotation.__args__): # pyright: ignore
if rf:
rf._is_optional = True
if len(annotation.__args__) <= 2: # pyright: ignore
if_obj_deserializer = _get_deserialize_callable_from_annotation(
next(a for a in annotation.__args__ if a is not _NONE_TYPE), module, rf # pyright: ignore
Expand Down Expand Up @@ -1049,6 +1054,7 @@ def _failsafe_deserialize_xml(
return None


# pylint: disable=too-many-instance-attributes
class _RestField:
def __init__(
self,
Expand All @@ -1068,6 +1074,7 @@ def __init__(
self._is_discriminator = is_discriminator
self._visibility = visibility
self._is_model = False
self._is_optional = False
self._default = default
self._format = format
self._is_multipart_file_input = is_multipart_file_input
Expand Down
Loading
Loading