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 runtime error for constant query parameter
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,11 @@ def append_pop_kwarg(key: str, pop_type: PopKwargType) -> None:
if is_content_type_optional and not type_annotation.startswith("Optional[")
else type_annotation
)
if kwarg.client_default_value is not None or kwarg.optional:
if kwarg.client_default_value is not None or kwarg.optional or kwarg.constant:
if check_client_input and kwarg.check_client_input:
default_value = f"self._config.{kwarg.client_name}"
elif kwarg.constant:
default_value = kwarg.type.get_declaration(None)
else:
default_value = kwarg.client_default_value_declaration
if check_kwarg_dict and (kwarg.location in [ParameterLocation.HEADER, ParameterLocation.QUERY]):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,8 @@ def test_decimal128_verify(client: ScalarClient):
def test_decimal_verify(client: ScalarClient):
prepare = client.decimal_verify.prepare_verify()
client.decimal_verify.verify(reduce(lambda x, y: x + y, prepare))


# open this test case after adopt new version of http-specs for https://github.com/microsoft/typespec/pull/8807
# def test_constant_query(client: ScalarClient):
# client.constant_query.post()
Loading