Skip to content

Commit 36825c1

Browse files
Copilotmsyyc
andauthored
[http-client-python] Map numeric scalar to Python float (#10563)
The Python emitter mapped the TypeSpec `numeric` scalar to `int`, truncating floating-point values for operations like: ```typespec op nooooooo(): numeric; ``` Since `numeric` is the parent of both integer and float scalars, `int` is unsound — `float` is the correct Python representation. ### Changes - **`packages/http-client-python/emitter/src/types.ts`**: In `sdkScalarKindToPythonKind`, change `numeric: "integer"` → `numeric: "float"`. - **Changeset**: Added a `fix` entry for `@typespec/http-client-python`. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>
1 parent 7ff22d0 commit 36825c1

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
changeKind: fix
3+
packages:
4+
- "@typespec/http-client-python"
5+
---
6+
7+
Fix TypeSpec `numeric` scalar type being emitted as `int` in Python; it is now emitted as `float`.

packages/http-client-python/emitter/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ function emitConstant(context: PythonSdkContext, type: SdkConstantType) {
436436
}
437437

438438
const sdkScalarKindToPythonKind: Record<string, string> = {
439-
numeric: "integer",
439+
numeric: "float",
440440
integer: "integer",
441441
safeint: "integer",
442442
int8: "integer",

0 commit comments

Comments
 (0)