Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

handle big ints better (#6768)

Shahmir Varqha008599b02ff2
diff --git a/frontend/src/components/editor/output/JsonOutput.tsx b/frontend/src/components/editor/output/JsonOutput.tsx
index 8368bbff56..7eb5d62418 100644
--- a/frontend/src/components/editor/output/JsonOutput.tsx
+++ b/frontend/src/components/editor/output/JsonOutput.tsx
@@ -194,6 +194,7 @@ const LEAF_RENDERERS = {
"video/": (value: string) => <VideoOutput src={value} />,
"text/html:": (value: string) => <HtmlOutput html={value} inline={true} />,
"text/plain+float:": (value: string) => <span>{value}</span>,
+ "text/plain+bigint:": (value: string) => <span>{value}</span>,
"text/plain+set:": (value: string) => <span>set{value}</span>,
"text/plain+tuple:": (value: string) => <span>{value}</span>,
"text/plain:": (value: string) => <CollapsibleTextOutput text={value} />,
@@ -351,6 +352,9 @@ function pythonJsonReplacer(_key: string, value: unknown): unknown {
if (typeof value === "object") {
return value;
}
+ if (typeof value === "bigint") {
+ return `${REPLACE_PREFIX}${value}${REPLACE_SUFFIX}`;
+ }
if (Array.isArray(value)) {
return value;
}
@@ -359,6 +363,11 @@ function pythonJsonReplacer(_key: string, value: unknown): unknown {
if (value.startsWith("text/plain+float:")) {
return `${REPLACE_PREFIX}${leafData(value)}${REPLACE_SUFFIX}`;
}
+ if (value.startsWith("text/plain+bigint:")) {
+ // Use BigInt to avoid precision loss
+ const number = BigInt(leafData(value));
+ return `${REPLACE_PREFIX}${number}${REPLACE_SUFFIX}`;
+ }
if (value.startsWith("text/plain+tuple:")) {
// replace first and last characters [] with ()
return `${REPLACE_PREFIX}(${leafData(value).slice(1, -1)})${REPLACE_SUFFIX}`;
diff --git a/frontend/src/components/editor/output/__tests__/json-output.test.ts b/frontend/src/components/editor/output/__tests__/json-output.test.ts
index 2ff76ba494..d76a6e2afd 100644
--- a/frontend/src/components/editor/output/__tests__/json-output.test.ts
+++ b/frontend/src/components/editor/output/__tests__/json-output.test.ts
@@ -218,6 +218,49 @@ describe("getCopyValue", () => {
`,
);
});
+
+ it("should handle bigint", () => {
+ const bigint = String(BigInt(2 ** 64));
+ const value = `text/plain+bigint:${bigint}`;
+ const result = getCopyValue(value);
+ expect(result).toMatchInlineSnapshot(`"18446744073709551616"`);
+
+ const nestedBigInt = {
+ key1: bigint, // this will be just a string
+ key2: `text/plain+bigint:${bigint}`, // this will convert to number
+ key3: true,
+ };
+ const nestedResult = getCopyValue(nestedBigInt);
+ expect(nestedResult).toMatchInlineSnapshot(
+ `
+ "{
+ "key1": "18446744073709551616",
+ "key2": 18446744073709551616,
+ "key3": True
+ }"
+ `,
+ );
+
+ const bigintRaw = BigInt(2 ** 64);
+ const bigintRawResult = getCopyValue(bigintRaw);
+ expect(bigintRawResult).toMatchInlineSnapshot(`"18446744073709551616"`);
+
+ const nestedBigIntRaw = {
+ key1: bigintRaw, // raw number
+ key2: `text/plain+bigint:${bigintRaw}`,
+ key3: true,
+ };
+ const nestedBigIntRawResult = getCopyValue(nestedBigIntRaw);
+ expect(nestedBigIntRawResult).toMatchInlineSnapshot(
+ `
+ "{
+ "key1": 18446744073709551616,
+ "key2": 18446744073709551616,
+ "key3": True
+ }"
+ `,
+ );
+ });
});
describe("determineMaxDisplayLength", () => {
diff --git a/frontend/src/components/editor/package-alert.tsx b/frontend/src/components/editor/package-alert.tsx
index bf681563dc..1a904df1b9 100644
--- a/frontend/src/components/editor/package-alert.tsx
+++ b/frontend/src/components/editor/package-alert.tsx
@@ -463,6 +463,7 @@ const ExtrasSelector: React.FC<ExtrasSelectorProps> = ({
<button
className="hover:bg-muted/50 rounded text-sm px-1 transition-colors border border-muted-foreground/30 hover:border-muted-foreground/60 min-w-0 flex-1 truncate text-left"
title={`Selected extras: ${selectedExtras.join(", ")}`}
+ type="button"
>
{selectedExtras.join(",")}
</button>
@@ -523,6 +524,7 @@ const ExtrasSelector: React.FC<ExtrasSelectorProps> = ({
!canSelectExtras && "opacity-50 cursor-not-allowed",
)}
title={canSelectExtras ? "Add extras" : "Loading extras..."}
+ type="button"
>
<PlusIcon className="w-3 h-3 shrink-0" />
</button>
@@ -619,6 +621,7 @@ const StreamingLogsViewer: React.FC<StreamingLogsViewerProps> = ({
<button
onClick={() => setIsExpanded(!isExpanded)}
className="flex items-center gap-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors"
+ type="button"
>
{isExpanded ? (
<ChevronDownIcon className="w-4 h-4" />
diff --git a/frontend/src/custom.d.ts b/frontend/src/custom.d.ts
index 720d05823b..ed3cecec8e 100644
--- a/frontend/src/custom.d.ts
+++ b/frontend/src/custom.d.ts
@@ -16,6 +16,8 @@ interface JSON {
text: string,
reviver?: (this: any, key: string, value: any) => any,
): unknown;
+
+ rawJSON(value: string): unknown;
}
// Improve type inference for Array.filter with BooleanConstructor
diff --git a/frontend/src/utils/__tests__/json-parser.test.ts b/frontend/src/utils/__tests__/json-parser.test.ts
index a3c681482f..6d060401ec 100644
--- a/frontend/src/utils/__tests__/json-parser.test.ts
+++ b/frontend/src/utils/__tests__/json-parser.test.ts
@@ -55,6 +55,19 @@ it("can fail to jsonParseWithSpecialChar", () => {
expect(jsonParseWithSpecialChar("[nan]")).toMatchInlineSnapshot("{}");
});
+it("can parse bigInts", () => {
+ const bigint = JSON.stringify({ bigint: { $bigint: "123456" } });
+ expect(jsonParseWithSpecialChar(bigint)).toEqual({ bigint: BigInt(123_456) });
+
+ const arrayOfBigInts = JSON.stringify([{ $bigint: "123456" }]);
+ expect(jsonParseWithSpecialChar(arrayOfBigInts)).toEqual([BigInt(123_456)]);
+
+ const nestedBigInt = JSON.stringify({ bigint: [{ $bigint: "123456" }] });
+ expect(jsonParseWithSpecialChar(nestedBigInt)).toEqual({
+ bigint: [BigInt(123_456)],
+ });
+});
+
it("can convert json to tsv", () => {
expect(jsonToTSV([])).toEqual("");
diff --git a/frontend/src/utils/json/json-parser.ts b/frontend/src/utils/json/json-parser.ts
index ca41ac5653..b66cb46d50 100644
--- a/frontend/src/utils/json/json-parser.ts
+++ b/frontend/src/utils/json/json-parser.ts
@@ -2,6 +2,18 @@
import type { JsonString } from "./base64";
+declare global {
+ interface BigInt {
+ toJSON(): unknown;
+ }
+}
+
+// Treat BigInts as numbers
+// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON#using_json_numbers
+BigInt.prototype.toJSON = function () {
+ return JSON.rawJSON(this.toString());
+};
+
/**
* Parse an attribute value as JSON.
* This also handles NaN, Infinity, and -Infinity.
@@ -12,7 +24,7 @@ export function jsonParseWithSpecialChar<T = unknown>(
// This regex handling is expensive and often not needed.
// We try to parse with JSON.parse first, and if that fails, we use the regex.
try {
- return JSON.parse(value) as T;
+ return JSON.parse(value, (_key, value) => sanitizeBigInt(value)) as T;
} catch {
// Do nothing
}
@@ -36,7 +48,7 @@ export function jsonParseWithSpecialChar<T = unknown>(
);
return JSON.parse(value, (_key, v) => {
if (typeof v !== "string") {
- return v;
+ return sanitizeBigInt(v);
}
if (v === `${CHAR}NaN${CHAR}`) {
return Number.NaN;
@@ -47,7 +59,7 @@ export function jsonParseWithSpecialChar<T = unknown>(
if (v === `${CHAR}-Infinity${CHAR}`) {
return Number.NEGATIVE_INFINITY;
}
- return v;
+ return sanitizeBigInt(v);
}) as T;
} catch {
return {} as T;
@@ -63,3 +75,16 @@ export function jsonToTSV(json: Record<string, unknown>[]) {
const values = json.map((row) => keys.map((key) => row[key]).join("\t"));
return `${keys.join("\t")}\n${values.join("\n")}`;
}
+
+/** Adapted from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/BigInt#use_within_json */
+function sanitizeBigInt(value: unknown): unknown {
+ if (
+ value !== null &&
+ typeof value === "object" &&
+ "$bigint" in value &&
+ typeof value.$bigint === "string"
+ ) {
+ return BigInt(value.$bigint);
+ }
+ return value;
+}
diff --git a/marimo/_output/data/data.py b/marimo/_output/data/data.py
index b981917c57..2829c908d3 100644
--- a/marimo/_output/data/data.py
+++ b/marimo/_output/data/data.py
@@ -185,20 +185,26 @@ def any_data(data: Union[str, bytes, io.BytesIO], ext: str) -> VirtualFile:
raise ValueError(f"Unsupported data type: {type(data)}")
+# JavaScript's safe integer limits
+MAX_SAFE_INTEGER = 9007199254740991
+MIN_SAFE_INTEGER = -9007199254740991
+BIGINT_KEY = "$bigint"
+
+
+def is_bigint(value: int | float) -> bool:
+ return value > MAX_SAFE_INTEGER or value < MIN_SAFE_INTEGER
+
+
def sanitize_json_bigint(
data: Union[str, dict[str, Any], list[dict[str, Any]]],
) -> str:
- """Sanitize JSON bigint to a string.
+ """Sanitize JSON big numbers to a string.
This is necessary because the frontend will round ints larger than
Number.MAX_SAFE_INTEGER to Number.MAX_SAFE_INTEGER.
"""
from json import dumps, loads
- # JavaScript's safe integer limits
- MAX_SAFE_INTEGER = 9007199254740991
- MIN_SAFE_INTEGER = -9007199254740991
-
def convert_key(key: Any) -> Any:
# Keys must be str, int, float, bool, or None
if key is None:
@@ -212,9 +218,12 @@ def sanitize_json_bigint(
return {convert_key(k): convert_bigint(v) for k, v in obj.items()} # type: ignore
elif isinstance(obj, list):
return [convert_bigint(item) for item in obj] # type: ignore
- elif isinstance(obj, int) and (
- obj > MAX_SAFE_INTEGER or obj < MIN_SAFE_INTEGER
- ):
+ elif isinstance(obj, int) and is_bigint(obj):
+ # If the value is outside the safe integer range, convert it to an object with a $bigint key
+ # Frontend will convert the object back to an integer.
+ return {BIGINT_KEY: str(obj)}
+ elif isinstance(obj, float) and is_bigint(obj):
+ # Decimals are not handled currently, we just convert them to strings.
return str(obj)
else:
return obj
diff --git a/marimo/_output/formatters/structures.py b/marimo/_output/formatters/structures.py
index cea108ee4f..c1b3f79aca 100644
--- a/marimo/_output/formatters/structures.py
+++ b/marimo/_output/formatters/structures.py
@@ -8,6 +8,7 @@ from typing import Any, Union
from marimo._messaging.mimetypes import KnownMimeType
from marimo._output import formatting
+from marimo._output.data.data import is_bigint
from marimo._output.formatters.formatter_factory import FormatterFactory
from marimo._output.formatters.repr_formatters import maybe_get_repr_formatter
from marimo._plugins.stateless.inspect import inspect
@@ -26,6 +27,8 @@ def _leaf_formatter(
if isinstance(value, str):
return value
if isinstance(value, int):
+ if is_bigint(value):
+ return f"text/plain+bigint:{value}"
return value
# floats are still converted to strings because JavaScript
# can't reliably distinguish between them (eg 1 and 1.0)
diff --git a/marimo/_smoke_tests/tables/complex_types.py b/marimo/_smoke_tests/tables/complex_types.py
index 4aaba830e1..6ae6c7a6c8 100644
--- a/marimo/_smoke_tests/tables/complex_types.py
+++ b/marimo/_smoke_tests/tables/complex_types.py
@@ -1,6 +1,6 @@
import marimo
-__generated_with = "0.15.5"
+__generated_with = "0.16.5"
app = marimo.App(width="medium")
@@ -110,11 +110,23 @@ def _(df):
@app.cell
def _(mo, pd, pl):
+ complex = [1 + 2j, 2 + 3j]
+
additional_types_pd = pd.DataFrame(
- {"complex": [1 + 2j, 2 + 3j], "bigint": [2**64, 2**127]}
+ {
+ "complex": complex,
+ "bigint": [2**64, 2**127],
+ "list_big_ints": [[1253397962952480469], [1253397962952480469]],
+ "large_floats": [[125339796295248046.9], [-12533979629524804.69]],
+ }
)
additional_types_pl = pl.DataFrame(
- {"complex": [1 + 2j, 2 + 3j], "bigint": [2**64, 2**65]}
+ {
+ "complex": complex,
+ "bigint": [2**64, -(2**65)],
+ "list_big_ints": [[1253397962952480469], [1253397962952480469]],
+ "large_floats": [[125339796295248046.9], [-12533979629524804.69]],
+ }
)
mo.vstack([additional_types_pd, additional_types_pl])
return
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 906405fa31..439aa50e2d 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -510,7 +510,7 @@ importers:
version: 2.2.2
'@codecov/vite-plugin':
specifier: ^1.9.1
'@csstools/postcss-light-dark-function':
specifier: ^2.0.10
version: 2.0.10([email protected])
@@ -519,13 +519,13 @@ importers:
version: 1.55.0
'@storybook/addon-docs':
specifier: ^9.1.8
'@storybook/addon-links':
specifier: ^9.1.8
'@storybook/react-vite':
specifier: ^9.1.8
'@swc-jotai/react-refresh':
specifier: ^0.3.0
version: 0.3.0
@@ -564,7 +564,7 @@ importers:
'@vitejs/plugin-react':
specifier: ^5.0.4
babel-plugin-react-compiler:
specifier: 19.1.0-rc.3
version: 19.1.0-rc.3
@@ -594,7 +594,7 @@ importers:
version: 1.3.0([email protected])
eslint-plugin-storybook:
specifier: ^9.0.14
eslint-plugin-unicorn:
specifier: ^54.0.0
version: 54.0.0([email protected])
@@ -627,7 +627,7 @@ importers:
version: 19.1.1([email protected])
storybook:
specifier: ^9.1.8
stylelint:
specifier: ^16.23.1
version: 16.23.1([email protected])
@@ -639,13 +639,13 @@ importers:
version: 4.1.13
vite:
specifier: npm:rolldown-vite@latest
vite-plugin-top-level-await:
specifier: ^1.6.0
vite-plugin-wasm:
specifier: ^3.5.0
vitest:
specifier: ^3.2.4
@@ -1906,8 +1906,8 @@ packages:
'@types/react':
optional: true
- '@napi-rs/[email protected]':
- resolution: {integrity: sha512-DXj75ewm11LIWUk198QSKUTxjyRjsBwk09MuMk5DGK+GDUtyPhhEHOGP/Xwwj3DjQXXkivoBirmOnKrLfc0+9g==}
+ '@napi-rs/[email protected]':
+ resolution: {integrity: sha512-SeDnOO0Tk7Okiq6DbXmmBODgOAb9dp9gjlphokTUxmt8U3liIP1ZsozBahH69j/RJv+Rfs6IwUKHTgQYJ/HBAw==}
resolution: {integrity: sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==}
@@ -3257,85 +3257,85 @@ packages:
'@codemirror/state': 6.x.x
'@codemirror/view': 6.x.x
- '@rolldown/[email protected]':
- resolution: {integrity: sha512-W5ZKF3TP3bOWuBfotAGp+UGjxOkGV7jRmIRbBA7NFjggx7Oi6vOmGDqpHEIX7kDCiry1cnIsWQaxNvWbMdkvzQ==}
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-TP8bcPOb1s6UmY5syhXrDn9k0XkYcw+XaoylTN4cJxf0JOVS2j682I3aTcpfT51hOFGr2bRwNKN9RZ19XxeQbA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [android]
- '@rolldown/[email protected]':
- resolution: {integrity: sha512-abw/wtgJA8OCgaTlL+xJxnN/Z01BwV1rfzIp5Hh9x+IIO6xOBfPsQ0nzi0+rWx3TyZ9FZXyC7bbC+5NpQ9EaXQ==}
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-kuVWnZsE4vEjMF/10SbSUyzucIW2zmdsqFghYMqy+fsjXnRHg0luTU6qWF8IqJf4Cbpm9NEZRnjIEPpAbdiSNQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [darwin]
- '@rolldown/[email protected]':
- resolution: {integrity: sha512-Y/UrZIRVr8CvXVEB88t6PeC46r1K9/QdPEo2ASE/b/KBEyXIx+QbM6kv9QfQVWU2Atly2+SVsQzxQsIvuk3lZQ==}
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-u9Ps4sh6lcmJ3vgLtyEg/x4jlhI64U0mM93Ew+tlfFdLDe7yKyA+Fe80cpr2n1mNCeZXrvTSbZluKpXQ0GxLjw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [darwin]
- '@rolldown/[email protected]':
- resolution: {integrity: sha512-zRM0oOk7BZiy6DoWBvdV4hyEg+j6+WcBZIMHVirMEZRu8hd18kZdJkg+bjVMfCEhwpWeFUfBfZ1qcaZ5UdYzlQ==}
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-h9lUtVtXgfbk/tnicMpbFfZ3DJvk5Zn2IvmlC1/e0+nUfwoc/TFqpfrRRqcNBXk/e+xiWMSKv6b0MF8N+Rtvlg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [freebsd]
- '@rolldown/[email protected]':
- resolution: {integrity: sha512-6RjFaC52QNwo7ilU8C5H7swbGlgfTkG9pudXwzr3VYyT18s0C9gLg3mvc7OMPIGqNxnQ0M5lU8j6aQCk2DTRVg==}
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-IX2C6bA6wM2rX/RvD75ko+ix9yxPKjKGGq7pOhB8wGI4Z4fqX5B1nDHga/qMDmAdCAR1m9ymzxkmqhm/AFYf7A==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm]
os: [linux]
- '@rolldown/[email protected]':
- resolution: {integrity: sha512-LMYHM5Sf6ROq+VUwHMDVX2IAuEsWTv4SnlFEedBnMGpvRuQ14lCmD4m5Q8sjyAQCgyha9oghdGoK8AEg1sXZKg==}
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-mcjd57vEj+CEQbZAzUiaxNzNgwwgOpFtZBWcINm8DNscvkXl5b/s622Z1dqGNWSdrZmdjdC6LWMvu8iHM6v9sQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [linux]
- '@rolldown/[email protected]':
- resolution: {integrity: sha512-/bNTYb9aKNhzdbPn3O4MK2aLv55AlrkUKPE4KNfBYjkoZUfDr4jWp7gsSlvTc5A/99V1RCm9axvt616ZzeXGyA==}
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-Pa8QMwlkrztTo/1mVjZmPIQ44tCSci10TBqxzVBvXVA5CFh5EpiEi99fPSll2dHG2uT4dCOMeC6fIhyDdb0zXA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [linux]
- '@rolldown/[email protected]':
- resolution: {integrity: sha512-n/SLa4h342oyeGykZdch7Y3GNCNliRPL4k5wkeZ/5eQZs+c6/ZG1SHCJQoy7bZcmxiMyaXs9HoFmv1PEKrZgWg==}
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-BgynXKMjeaX4AfWLARhOKDetBOOghnSiVRjAHVvhiAaDXgdQN8e65mSmXRiVoVtD3cHXx/cfU8Gw0p0K+qYKVQ==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [linux]
- '@rolldown/[email protected]':
- resolution: {integrity: sha512-4PSd46sFzqpLHSGdaSViAb1mk55sCUMpJg+X8ittXaVocQsV3QLG/uydSH8RyL0ngHX5fy3D70LcCzlB15AgHw==}
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-VIsoPlOB/tDSAw9CySckBYysoIBqLeps1/umNSYUD8pMtalJyzMTneAVI1HrUdf4ceFmQ5vARoLIXSsPwVFxNg==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [linux]
- '@rolldown/[email protected]':
- resolution: {integrity: sha512-BmWoeJJyeZXmZBcfoxG6J9+rl2G7eO47qdTkAzEegj4n3aC6CBIHOuDcbE8BvhZaEjQR0nh0nJrtEDlt65Q7Sw==}
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-YDXTxVJG67PqTQMKyjVJSddoPbSWJ4yRz/E3xzTLHqNrTDGY0UuhG8EMr8zsYnfH/0cPFJ3wjQd/hJWHuR6nkA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [openharmony]
- '@rolldown/[email protected]':
- resolution: {integrity: sha512-2Ft32F7uiDTrGZUKws6CLNTlvTWHC33l4vpXrzUucf9rYtUThAdPCOt89Pmn13tNX6AulxjGEP2R0nZjTSW3eQ==}
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-3M+2DmorXvDuAIGYQ9Z93Oy1G9ETkejLwdXXb1uRTgKN9pMcu7N+KG2zDrJwqyxeeLIFE22AZGtSJm3PJbNu9Q==}
engines: {node: '>=14.0.0'}
cpu: [wasm32]
- '@rolldown/[email protected]':
- resolution: {integrity: sha512-hC1kShXW/z221eG+WzQMN06KepvPbMBknF0iGR3VMYJLOe9gwnSTfGxFT5hf8XrPv7CEZqTWRd0GQpkSHRbGsw==}
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-/B1j1pJs33y9ywtslOMxryUPHq8zIGu/OGEc2gyed0slimJ8fX2uR/SaJVhB4+NEgCFIeYDR4CX6jynAkeRuCA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [arm64]
os: [win32]
- '@rolldown/[email protected]':
- resolution: {integrity: sha512-AICBYromawouGjj+GS33369E8Vwhy6UwhQEhQ5evfS8jPCsyVvoICJatbDGDGH01dwtVGLD5eDFzPicUOVpe4g==}
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-29oG1swCz7hNP+CQYrsM4EtylsKwuYzM8ljqbqC5TsQwmKat7P8ouDpImsqg/GZxFSXcPP9ezQm0Q0wQwGM3JA==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [ia32]
os: [win32]
- '@rolldown/[email protected]':
- resolution: {integrity: sha512-XpZ0M+tjoEiSc9c+uZR7FCnOI0uxDRNs1elGOMjeB0pUP1QmvVbZGYNsyLbLoP4u7e3VQN8rie1OQ8/mB6rcJg==}
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-eWBV1Ef3gfGNehxVGCyXs7wLayRIgCmyItuCZwYYXW5bsk4EvR4n2GP5m3ohjnx7wdiY3nLmwQfH2Knb5gbNZw==}
engines: {node: ^20.19.0 || >=22.12.0}
cpu: [x64]
os: [win32]
@@ -3343,8 +3343,8 @@ packages:
'@rolldown/[email protected]':
resolution: {integrity: sha512-N/ICGKleNhA5nc9XXQG/kkKHJ7S55u0x0XUJbbkmdCnFuoRkM1Il12q9q0eX19+M7KKUEPw/daUPIRnxhcxAIw==}
- '@rolldown/[email protected]':
- resolution: {integrity: sha512-N7pQzk9CyE7q0bBN/q0J8s6Db279r5kUZc6d7/wWRe9/zXqC52HQovVyu6iXPIDY4BEzzgbVLhVFXrOuGJ22ZQ==}
+ '@rolldown/[email protected]':
+ resolution: {integrity: sha512-5Uxg7fQUCmfhax7FJke2+8B6cqgeUJUD9o2uXIKXhD+mG0mL6NObmVoi9wXEU1tY89mZKgAYA6fTbftx3q2ZPQ==}
'@rollup/[email protected]':
resolution: {integrity: sha512-10monEYsBp3scM4/ND4LNH5Rxvh3e/cVeL3jWTgZ2SrQ+BmUoQcopVQvnaMcOnykb1VkxUFuDAN+0FnpTFRy2A==}
@@ -8651,8 +8651,8 @@ packages:
resolution: {integrity: sha512-IXgzBWvWQwE6PrDI05OvmXUIruQTcoMDzRsOd5CDvHCVLcLHMTSYvOK5Cm46kWqlV3yAbuSpBZdJ5oP5OUoStg==}
- resolution: {integrity: sha512-cK6tCmZyEC0KRAcXTjQ+ara+wkqmaE7WUoI0ZfZzDuvaRaZ3mtvbhTJc4cH+PjKRok++++Z1bZZaNlf3+SnnGA==}
+ resolution: {integrity: sha512-bNUI0r4RuZxLeip7sOcZK3y4eYUcMAMM6ys68tbU/KWDH8lqaPFYE03Doc04Dz94jHmVg1OWyeBqlDOYntsLsA==}
engines: {node: ^20.19.0 || >=22.12.0}
hasBin: true
peerDependencies:
@@ -8691,8 +8691,8 @@ packages:
yaml:
optional: true
- resolution: {integrity: sha512-xaPcckj+BbJhYLsv8gOqezc8EdMcKKe/gk8v47B0KPvgABDrQ0qmNPAiT/gh9n9Foe0bUkEv2qzj42uU5q1WRg==}
+ resolution: {integrity: sha512-6RcqyRx0tY1MlRLnjXPp/849Rl/CPFhzpGGwNPEPjKwqBMqPq/Rbbkxasa8s0x+IkUk46ty4jazb5skZ/Vgdhw==}
engines: {node: ^20.19.0 || >=22.12.0}
hasBin: true
@@ -10583,11 +10583,11 @@ snapshots:
unplugin: 1.16.1
zod: 3.25.76
dependencies:
'@codecov/bundler-plugin-core': 1.9.1
unplugin: 1.16.1
'@codemirror/[email protected]':
dependencies:
@@ -11333,12 +11333,12 @@ snapshots:
dependencies:
'@sinclair/typebox': 0.27.8
dependencies:
glob: 10.4.5
magic-string: 0.30.18
react-docgen-typescript: 2.4.0([email protected])
optionalDependencies:
typescript: 5.9.2
@@ -11677,7 +11677,7 @@ snapshots:
optionalDependencies:
'@types/react': 19.1.12
- '@napi-rs/[email protected]':
+ '@napi-rs/[email protected]':
dependencies:
'@emnapi/core': 1.5.0
'@emnapi/runtime': 1.5.0
@@ -13628,53 +13628,53 @@ snapshots:
'@codemirror/state': 6.5.2
'@codemirror/view': 6.38.5
- '@rolldown/[email protected]':
+ '@rolldown/[email protected]':
optional: true
- '@rolldown/[email protected]':
+ '@rolldown/[email protected]':
optional: true
- '@rolldown/[email protected]':
+ '@rolldown/[email protected]':
optional: true
- '@rolldown/[email protected]':
+ '@rolldown/[email protected]':
optional: true
- '@rolldown/[email protected]':
+ '@rolldown/[email protected]':
optional: true
- '@rolldown/[email protected]':
+ '@rolldown/[email protected]':
optional: true
- '@rolldown/[email protected]':
+ '@rolldown/[email protected]':
optional: true
- '@rolldown/[email protected]':
+ '@rolldown/[email protected]':
optional: true
- '@rolldown/[email protected]':
+ '@rolldown/[email protected]':
optional: true
- '@rolldown/[email protected]':
+ '@rolldown/[email protected]':
optional: true
- '@rolldown/[email protected]':
+ '@rolldown/[email protected]':
dependencies:
- '@napi-rs/wasm-runtime': 1.0.6
+ '@napi-rs/wasm-runtime': 1.0.7
optional: true
- '@rolldown/[email protected]':
+ '@rolldown/[email protected]':
optional: true
- '@rolldown/[email protected]':
+ '@rolldown/[email protected]':
optional: true
- '@rolldown/[email protected]':
+ '@rolldown/[email protected]':
optional: true
'@rolldown/[email protected]': {}
- '@rolldown/[email protected]': {}
+ '@rolldown/[email protected]': {}
optionalDependencies:
@@ -13794,36 +13794,36 @@ snapshots:
'@standard-schema/[email protected]': {}
dependencies:
'@mdx-js/react': 3.1.0(@types/[email protected])([email protected])
react: 19.1.1
react-dom: 19.1.1([email protected])
ts-dedent: 2.2.0
transitivePeerDependencies:
- '@types/react'
dependencies:
'@storybook/global': 5.0.0
optionalDependencies:
react: 19.1.1
dependencies:
ts-dedent: 2.2.0
dependencies:
unplugin: 1.16.1
'@storybook/[email protected]': {}
@@ -13833,39 +13833,39 @@ snapshots:
react: 19.1.1
react-dom: 19.1.1([email protected])
dependencies:
react: 19.1.1
react-dom: 19.1.1([email protected])
dependencies:
'@rollup/pluginutils': 5.2.0([email protected])
find-up: 7.0.0
magic-string: 0.30.18
react: 19.1.1
react-docgen: 8.0.0
react-dom: 19.1.1([email protected])
resolve: 1.22.10
tsconfig-paths: 4.2.0
transitivePeerDependencies:
- rollup
- supports-color
- typescript
dependencies:
'@storybook/global': 5.0.0
react: 19.1.1
react-dom: 19.1.1([email protected])
optionalDependencies:
typescript: 5.9.2
@@ -14627,7 +14627,7 @@ snapshots:
'@connectrpc/connect': 1.6.1(@bufbuild/[email protected])
'@connectrpc/connect-web': 1.6.1(@bufbuild/[email protected])(@connectrpc/[email protected](@bufbuild/[email protected]))
dependencies:
'@babel/core': 7.28.4
'@babel/plugin-transform-react-jsx-self': 7.27.1(@babel/[email protected])
@@ -14635,7 +14635,7 @@ snapshots:
'@rolldown/pluginutils': 1.0.0-beta.38
'@types/babel__core': 7.20.5
react-refresh: 0.17.0
transitivePeerDependencies:
- supports-color
@@ -14653,14 +14653,14 @@ snapshots:
chai: 5.2.1
tinyrainbow: 2.0.0
dependencies:
'@vitest/spy': 3.2.4
estree-walker: 3.0.3
magic-string: 0.30.18
optionalDependencies:
'@vitest/[email protected]':
dependencies:
@@ -16338,11 +16338,11 @@ snapshots:
eslint: 8.57.1
globals: 13.24.0
dependencies:
'@typescript-eslint/utils': 8.37.0([email protected])([email protected])
eslint: 8.57.1
transitivePeerDependencies:
- supports-color
- typescript
@@ -19935,14 +19935,14 @@ snapshots:
dependencies:
'@oxc-project/runtime': 0.92.0
fdir: 6.5.0([email protected])
lightningcss: 1.30.2
picomatch: 4.0.3
postcss: 8.5.6
- rolldown: 1.0.0-beta.42
+ rolldown: 1.0.0-beta.43
tinyglobby: 0.2.15
optionalDependencies:
'@types/node': 24.3.1
@@ -19952,26 +19952,26 @@ snapshots:
terser: 5.44.0
yaml: 2.8.1
dependencies:
'@oxc-project/types': 0.94.0
- '@rolldown/pluginutils': 1.0.0-beta.42
+ '@rolldown/pluginutils': 1.0.0-beta.43
ansis: 4.2.0
optionalDependencies:
- '@rolldown/binding-android-arm64': 1.0.0-beta.42
- '@rolldown/binding-darwin-arm64': 1.0.0-beta.42
- '@rolldown/binding-darwin-x64': 1.0.0-beta.42
- '@rolldown/binding-freebsd-x64': 1.0.0-beta.42
- '@rolldown/binding-linux-arm-gnueabihf': 1.0.0-beta.42
- '@rolldown/binding-linux-arm64-gnu': 1.0.0-beta.42
- '@rolldown/binding-linux-arm64-musl': 1.0.0-beta.42
- '@rolldown/binding-linux-x64-gnu': 1.0.0-beta.42
- '@rolldown/binding-linux-x64-musl': 1.0.0-beta.42
- '@rolldown/binding-openharmony-arm64': 1.0.0-beta.42
- '@rolldown/binding-wasm32-wasi': 1.0.0-beta.42
- '@rolldown/binding-win32-arm64-msvc': 1.0.0-beta.42
- '@rolldown/binding-win32-ia32-msvc': 1.0.0-beta.42
- '@rolldown/binding-win32-x64-msvc': 1.0.0-beta.42
+ '@rolldown/binding-android-arm64': 1.0.0-beta.43
+ '@rolldown/binding-darwin-arm64': 1.0.0-beta.43
+ '@rolldown/binding-darwin-x64': 1.0.0-beta.43
+ '@rolldown/binding-freebsd-x64': 1.0.0-beta.43
+ '@rolldown/binding-linux-arm-gnueabihf': 1.0.0-beta.43
+ '@rolldown/binding-linux-arm64-gnu': 1.0.0-beta.43
+ '@rolldown/binding-linux-arm64-musl': 1.0.0-beta.43
+ '@rolldown/binding-linux-x64-gnu': 1.0.0-beta.43
+ '@rolldown/binding-linux-x64-musl': 1.0.0-beta.43
+ '@rolldown/binding-openharmony-arm64': 1.0.0-beta.43
+ '@rolldown/binding-wasm32-wasi': 1.0.0-beta.43
+ '@rolldown/binding-win32-arm64-msvc': 1.0.0-beta.43
+ '@rolldown/binding-win32-ia32-msvc': 1.0.0-beta.43
+ '@rolldown/binding-win32-x64-msvc': 1.0.0-beta.43
dependencies:
@@ -20292,13 +20292,13 @@ snapshots:
es-errors: 1.3.0
internal-slot: 1.1.0
dependencies:
'@storybook/global': 5.0.0
'@testing-library/jest-dom': 6.8.0
'@testing-library/user-event': 14.6.1(@testing-library/[email protected])
'@vitest/expect': 3.2.4
'@vitest/spy': 3.2.4
better-opn: 3.0.2
esbuild: 0.25.9
@@ -21478,7 +21478,7 @@ snapshots:
debug: 4.4.1([email protected])
es-module-lexer: 1.7.0
pathe: 2.0.3
transitivePeerDependencies:
- '@types/node'
- esbuild
@@ -21493,26 +21493,26 @@ snapshots:
- tsx
- yaml
dependencies:
'@rollup/plugin-virtual': 3.0.2([email protected])
'@swc/core': 1.12.14(@swc/[email protected])
'@swc/wasm': 1.13.2
uuid: 10.0.0
transitivePeerDependencies:
- '@swc/helpers'
- rollup
dependencies:
dependencies:
'@types/chai': 5.2.2
'@vitest/expect': 3.2.4
'@vitest/pretty-format': 3.2.4
'@vitest/runner': 3.2.4
'@vitest/snapshot': 3.2.4
@@ -21530,7 +21530,7 @@ snapshots:
tinyglobby: 0.2.15
tinypool: 1.1.1
tinyrainbow: 2.0.0
why-is-node-running: 2.3.0
optionalDependencies:
diff --git a/tests/_output/formatters/test_structures.py b/tests/_output/formatters/test_structures.py
index 22280674ad..34debcf61c 100644
--- a/tests/_output/formatters/test_structures.py
+++ b/tests/_output/formatters/test_structures.py
@@ -86,13 +86,15 @@ def test_format_structure_simple() -> None:
def test_format_structure_nested() -> None:
StructuresFormatter().register()
+ bigint = 2**64
+
nested_structure = {
"a": [1, 2, {"b": 3, "c": True}],
- "d": (4, 5, False, 1.0),
+ "d": (4, 5, False, 1.0, bigint),
}
assert get_and_format(nested_structure) == (
"application/json",
- '{"a": [1, 2, {"b": 3, "c": true}], "d": [4, 5, false, "text/plain+float:1.0"]}',
+ f'{{"a": [1, 2, {{"b": 3, "c": true}}], "d": [4, 5, false, "text/plain+float:1.0", "text/plain+bigint:{bigint}"]}}',
)
@@ -226,6 +228,11 @@ def test_format_structure_set() -> None:
assert format_structure([test_set]) == (["text/plain+set:{1, 2, 3}"])
+def test_format_structure_bigint() -> None:
+ bigint = 2**64
+ assert format_structure([bigint]) == ([f"text/plain+bigint:{bigint}"])
+
+
def test_format_structure_tuple() -> None:
test_tuple = (1, 2, 3)
assert format_structure(test_tuple) == (1, 2, 3)
diff --git a/tests/_output/test_data.py b/tests/_output/test_data.py
index c9e9a24350..8df7900e49 100644
--- a/tests/_output/test_data.py
+++ b/tests/_output/test_data.py
@@ -41,21 +41,21 @@ def test_sanitize_json_bigint() -> None:
json_str = '{"bigint": 9007199254740992}'
assert (
mo_data.sanitize_json_bigint(json_str)
- == '{"bigint":"9007199254740992"}'
+ == '{"bigint":{"$bigint":"9007199254740992"}}'
)
# Test with dict input
data_dict = {"bigint": 9007199254740992}
assert (
mo_data.sanitize_json_bigint(data_dict)
- == '{"bigint":"9007199254740992"}'
+ == '{"bigint":{"$bigint":"9007199254740992"}}'
)
# Test with list of dicts input
data_list = [{"bigint": 9007199254740992}]
assert (
mo_data.sanitize_json_bigint(data_list)
- == '[{"bigint":"9007199254740992"}]'
+ == '[{"bigint":{"$bigint":"9007199254740992"}}]'
)
# Test with regular numbers (should not be converted)
@@ -69,7 +69,7 @@ def test_sanitize_json_bigint() -> None:
}
assert (
mo_data.sanitize_json_bigint(data_dict)
- == '{"bigint":"9007199254740992","nested":{"bigint":"9007199254740993","regular":42}}' # noqa: E501
+ == '{"bigint":{"$bigint":"9007199254740992"},"nested":{"bigint":{"$bigint":"9007199254740993"},"regular":42}}' # noqa: E501
)
@@ -82,3 +82,11 @@ def test_sanitize_json_bigint_keys() -> None:
assert (
mo_data.sanitize_json_bigint(data_dict) == '{"2021-01-01":"date key"}'
)
+
+
+def test_sanitize_json_bigint_floats() -> None:
+ data_dict = {"float": 125339796295248046.9}
+ assert (
+ mo_data.sanitize_json_bigint(data_dict)
+ == '{"float":"1.2533979629524805e+17"}'
+ )
diff --git a/tests/_plugins/ui/_impl/tables/test_narwhals.py b/tests/_plugins/ui/_impl/tables/test_narwhals.py
index 8e4ee80f63..1feb8b99e3 100644
--- a/tests/_plugins/ui/_impl/tables/test_narwhals.py
+++ b/tests/_plugins/ui/_impl/tables/test_narwhals.py
@@ -12,6 +12,7 @@ import pytest
from marimo._data.models import BinValue, ColumnStats
from marimo._dependencies.dependencies import DependencyManager
+from marimo._output.data.data import BIGINT_KEY
from marimo._plugins.ui._impl.table import SortArgs
from marimo._plugins.ui._impl.tables.format import FormatMapping
from marimo._plugins.ui._impl.tables.narwhals_table import (
@@ -840,9 +841,9 @@ def test_to_json_bigint(df: Any) -> None:
assert json_data[0]["A"] == 20
assert json_data[0]["B"] == -20
- # Large integers should be converted to strings
- assert json_data[1]["A"] == "9007199254740992"
- assert json_data[1]["B"] == "-9007199254740992"
+ # Large integers should be converted to objects
+ assert json_data[1]["A"] == {BIGINT_KEY: "9007199254740992"}
+ assert json_data[1]["B"] == {BIGINT_KEY: "-9007199254740992"}
@pytest.mark.skipif(not HAS_DEPS, reason="optional dependencies not installed")
diff --git a/tests/_plugins/ui/_impl/tables/test_pandas_table.py b/tests/_plugins/ui/_impl/tables/test_pandas_table.py
index 18e9f33092..eaa2a892bf 100644
--- a/tests/_plugins/ui/_impl/tables/test_pandas_table.py
+++ b/tests/_plugins/ui/_impl/tables/test_pandas_table.py
@@ -12,6 +12,7 @@ import pytest
from marimo._data.models import ColumnStats
from marimo._dependencies.dependencies import DependencyManager
+from marimo._output.data.data import BIGINT_KEY
from marimo._plugins.ui._impl.table import SortArgs
from marimo._plugins.ui._impl.tables.format import FormatMapping
from marimo._plugins.ui._impl.tables.pandas_table import (
@@ -1189,9 +1190,9 @@ class TestPandasTableManager(unittest.TestCase):
assert json_data[0]["A"] == 20
assert json_data[0]["B"] == -20
- # Large integers should be converted to strings
- assert json_data[1]["A"] == "9007199254740992"
- assert json_data[1]["B"] == "-9007199254740992"
+ # Large integers should be converted to objects
+ assert json_data[1]["A"] == {BIGINT_KEY: "9007199254740992"}
+ assert json_data[1]["B"] == {BIGINT_KEY: "-9007199254740992"}
def test_to_json_uuid_encoding(self) -> None:
import uuid
diff --git a/tests/_plugins/ui/_impl/tables/test_polars_table.py b/tests/_plugins/ui/_impl/tables/test_polars_table.py
index b357f04108..a40ee4815a 100644
--- a/tests/_plugins/ui/_impl/tables/test_polars_table.py
+++ b/tests/_plugins/ui/_impl/tables/test_polars_table.py
@@ -11,6 +11,7 @@ import pytest
from marimo._data.models import ColumnStats
from marimo._dependencies.dependencies import DependencyManager
+from marimo._output.data.data import BIGINT_KEY
from marimo._plugins.ui._impl.table import SortArgs
from marimo._plugins.ui._impl.tables.format import FormatMapping
from marimo._plugins.ui._impl.tables.polars_table import (
@@ -961,9 +962,9 @@ class TestPolarsTableManagerFactory(unittest.TestCase):
assert json_data[0]["A"] == 20
assert json_data[0]["B"] == -20
- # Large integers should be converted to strings
- assert json_data[1]["A"] == "9007199254740992"
- assert json_data[1]["B"] == "-9007199254740992"
+ # Large integers should be converted to objects
+ assert json_data[1]["A"] == {BIGINT_KEY: "9007199254740992"}
+ assert json_data[1]["B"] == {BIGINT_KEY: "-9007199254740992"}
@pytest.mark.xfail(
reason="Polars does not support writing binary data to JSON"