Skip to content

Commit

Permalink
fix unused import
Browse files Browse the repository at this point in the history
  • Loading branch information
msyyc committed Jan 14, 2025
1 parent 76e4546 commit 6c94bae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ def get_request_builder_import(
)
return file_import

@property
def need_deserialize(self) -> bool:
return any(r.type and isinstance(r.type, ModelType) for r in self.responses)

def imports( # pylint: disable=too-many-branches, disable=too-many-statements
self, async_mode: bool, **kwargs: Any
) -> FileImport:
Expand Down Expand Up @@ -452,7 +456,7 @@ def imports( # pylint: disable=too-many-branches, disable=too-many-statements
file_import.add_import("json", ImportType.STDLIB)
if any(xml_serializable(str(r.default_content_type)) for r in self.responses):
file_import.add_submodule_import(relative_path, "_deserialize_xml", ImportType.LOCAL)
elif any(r.type for r in self.responses):
elif self.need_deserialize:
file_import.add_submodule_import(relative_path, "_deserialize", ImportType.LOCAL)
if self.default_error_deserialization or self.non_default_errors:
file_import.add_submodule_import(relative_path, "_failsafe_deserialize", ImportType.LOCAL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def imports(self, async_mode: bool, **kwargs: Any) -> FileImport:
if self.code_model.options["models_mode"] == "dpg":
relative_path = self.code_model.get_relative_import_path(serialize_namespace, module_name="_model_base")
file_import.merge(self.item_type.imports(**kwargs))
if self.default_error_deserialization or any(r.type for r in self.responses):
if self.default_error_deserialization or self.need_deserialize:
file_import.add_submodule_import(relative_path, "_deserialize", ImportType.LOCAL)
return file_import

Expand Down

0 comments on commit 6c94bae

Please sign in to comment.