diff --git a/.chronus/changes/python-fix-api-version-docstring-2026-3-23.md b/.chronus/changes/python-fix-api-version-docstring-2026-3-23.md new file mode 100644 index 00000000000..881973847e6 --- /dev/null +++ b/.chronus/changes/python-fix-api-version-docstring-2026-3-23.md @@ -0,0 +1,7 @@ +--- +changeKind: fix +packages: + - "@typespec/http-client-python" +--- + +Remove `None` from "Known values" in `api_version` parameter docstring since the parameter is typed as `str` and `None` is not a valid API version value. diff --git a/packages/http-client-python/generator/pygen/codegen/models/parameter.py b/packages/http-client-python/generator/pygen/codegen/models/parameter.py index d637e016446..bcca96fa75c 100644 --- a/packages/http-client-python/generator/pygen/codegen/models/parameter.py +++ b/packages/http-client-python/generator/pygen/codegen/models/parameter.py @@ -109,10 +109,16 @@ def description(self) -> str: if type_description: base_description = add_to_description(base_description, type_description) if self.optional and isinstance(self.type, ConstantType): - base_description = add_to_description( - base_description, - f"Known values are {self.get_declaration()} and None.", - ) + if self.is_api_version: + base_description = add_to_description( + base_description, + f"Known values are {self.get_declaration()}.", + ) + else: + base_description = add_to_description( + base_description, + f"Known values are {self.get_declaration()} and None.", + ) if not (self.optional or self.client_default_value): base_description = add_to_description(base_description, "Required.") if self.client_default_value is not None: