From 3c077f8adf44ae1c10540bc9a191fb2b370164d4 Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Wed, 16 Apr 2025 11:04:56 +0800 Subject: [PATCH 1/2] Fix docstring --- .../generator/pygen/codegen/models/enum_type.py | 4 ++-- .../generator/pygen/codegen/models/model_type.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/http-client-python/generator/pygen/codegen/models/enum_type.py b/packages/http-client-python/generator/pygen/codegen/models/enum_type.py index 02c04c2db08..f32a0931b06 100644 --- a/packages/http-client-python/generator/pygen/codegen/models/enum_type.py +++ b/packages/http-client-python/generator/pygen/codegen/models/enum_type.py @@ -52,7 +52,7 @@ def docstring_type(self, **kwargs: Any) -> str: """The python type used for RST syntax input and type annotation.""" type_annotation = self.value_type.type_annotation(**kwargs) - enum_type_annotation = f"{self.code_model.namespace}.models.{self.name}" + enum_type_annotation = f"{self.enum_type.client_namespace}.models.{self.name}" return f"{type_annotation} or ~{enum_type_annotation}" def get_json_template_representation( @@ -198,7 +198,7 @@ def docstring_type(self, **kwargs: Any) -> str: """The python type used for RST syntax input and type annotation.""" if self.code_model.options["models_mode"]: type_annotation = self.value_type.type_annotation(**kwargs) - enum_type_annotation = f"{self.code_model.namespace}.models.{self.name}" + enum_type_annotation = f"{self.client_namespace}.models.{self.name}" return f"{type_annotation} or ~{enum_type_annotation}" return self.value_type.type_annotation(**kwargs) diff --git a/packages/http-client-python/generator/pygen/codegen/models/model_type.py b/packages/http-client-python/generator/pygen/codegen/models/model_type.py index 9784bc7a5a2..3b0952c61a9 100644 --- a/packages/http-client-python/generator/pygen/codegen/models/model_type.py +++ b/packages/http-client-python/generator/pygen/codegen/models/model_type.py @@ -292,7 +292,7 @@ def type_annotation(self, **kwargs: Any) -> str: def docstring_type(self, **kwargs: Any) -> str: type_annotation = self.type_annotation(need_model_alias=False, skip_quote=True, **kwargs) - return f"~{self.code_model.namespace}.models.{type_annotation}" + return f"~{self.client_namespace}.models.{type_annotation}" def docstring_text(self, **kwargs: Any) -> str: return self.name From a1b1b2244f7af6865312166317d9b83a1ba885bb Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Wed, 16 Apr 2025 11:09:58 +0800 Subject: [PATCH 2/2] add changelog --- .../changes/multi-namespace-doc-fix-2025-3-16-11-9-36.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .chronus/changes/multi-namespace-doc-fix-2025-3-16-11-9-36.md diff --git a/.chronus/changes/multi-namespace-doc-fix-2025-3-16-11-9-36.md b/.chronus/changes/multi-namespace-doc-fix-2025-3-16-11-9-36.md new file mode 100644 index 00000000000..3174ded7dd5 --- /dev/null +++ b/.chronus/changes/multi-namespace-doc-fix-2025-3-16-11-9-36.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/http-client-python" +--- + +Fix docstring type for multi namespaces \ No newline at end of file