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
7 changes: 7 additions & 0 deletions .chronus/changes/multi-namespace-doc-fix-2025-3-16-11-9-36.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
changeKind: fix
packages:
- "@typespec/http-client-python"
---

Fix docstring type for multi namespaces
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading