Skip to content
Merged
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:
- "@typespec/http-client-python"
---

Fix import of `_deserialize` in mix of xml and non-xml models
Original file line number Diff line number Diff line change
Expand Up @@ -449,21 +449,22 @@ def imports( # pylint: disable=too-many-branches, disable=too-many-statements
file_import.add_import("json", ImportType.STDLIB)
if self.enable_import_deserialize_xml:
file_import.add_submodule_import(relative_path, "_deserialize_xml", ImportType.LOCAL)
elif self.need_deserialize:
if any(
r.type
and not isinstance(r.type, BinaryIteratorType)
and not xml_serializable(str(r.default_content_type))
for r in self.responses
):
file_import.add_submodule_import(relative_path, "_deserialize", ImportType.LOCAL)
if self.default_error_deserialization(serialize_namespace) or self.non_default_errors:
xml_non_default_errors = any(
xml_serializable(str(e.default_content_type)) for e in self.non_default_errors
)
try:
default_error = next(e for e in self.exceptions if "default" in e.status_codes and e.type)
except StopIteration:
default_error = None
if xml_non_default_errors or (
default_error and xml_serializable(str(default_error.default_content_type))
):
all_errors = list(self.non_default_errors) + ([default_error] if default_error else [])
if any(xml_serializable(str(e.default_content_type)) for e in all_errors):
file_import.add_submodule_import(relative_path, "_failsafe_deserialize_xml", ImportType.LOCAL)
else:
if any(not xml_serializable(str(e.default_content_type)) for e in all_errors):
file_import.add_submodule_import(relative_path, "_failsafe_deserialize", ImportType.LOCAL)
return file_import

Expand Down
18 changes: 9 additions & 9 deletions packages/http-client-python/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/http-client-python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@azure-tools/typespec-azure-core": ">=0.66.0 <1.0.0",
"@azure-tools/typespec-azure-resource-manager": ">=0.66.0 <1.0.0",
"@azure-tools/typespec-azure-rulesets": ">=0.66.0 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.66.3 <1.0.0",
"@azure-tools/typespec-client-generator-core": ">=0.66.4 <1.0.0",
"@typespec/compiler": "^1.10.0",
"@typespec/http": "^1.10.0",
"@typespec/openapi": "^1.10.0",
Expand All @@ -81,7 +81,7 @@
"@azure-tools/typespec-azure-core": "~0.66.0",
"@azure-tools/typespec-azure-resource-manager": "~0.66.0",
"@azure-tools/typespec-azure-rulesets": "~0.66.0",
"@azure-tools/typespec-client-generator-core": "~0.66.3",
"@azure-tools/typespec-client-generator-core": "~0.66.4",
"@azure-tools/azure-http-specs": "0.1.0-alpha.39-dev.4",
"@typespec/compiler": "^1.10.0",
"@typespec/http": "^1.10.0",
Expand Down
Loading