2
2
from io import StringIO
3
3
from itertools import islice
4
4
import os
5
- from typing import Any , Callable , Dict , List , Optional , Type , Union
5
+ from typing import Any , Callable , Optional , Type
6
6
7
7
import numpy as np
8
8
13
13
from pandas .core .dtypes .common import ensure_str , is_period_dtype
14
14
15
15
from pandas import DataFrame , MultiIndex , Series , compat , isna , to_datetime
16
- from pandas ._typing import Scalar
16
+ from pandas ._typing import JSONSerializable
17
17
from pandas .core .reshape .concat import concat
18
18
19
19
from pandas .io .common import (
34
34
35
35
TABLE_SCHEMA_VERSION = "0.20.0"
36
36
37
- Serializable = Union [Scalar , List , Dict ]
38
-
39
37
40
38
# interface to/from
41
39
def to_json (
@@ -46,7 +44,7 @@ def to_json(
46
44
double_precision : int = 10 ,
47
45
force_ascii : bool = True ,
48
46
date_unit : str = "ms" ,
49
- default_handler : Optional [Callable [[Any ], Serializable ]] = None ,
47
+ default_handler : Optional [Callable [[Any ], JSONSerializable ]] = None ,
50
48
lines : bool = False ,
51
49
compression : Optional [str ] = "infer" ,
52
50
index : bool = True ,
@@ -110,7 +108,7 @@ def __init__(
110
108
ensure_ascii : bool ,
111
109
date_unit : str ,
112
110
index : bool ,
113
- default_handler : Optional [Callable [[Any ], Serializable ]] = None ,
111
+ default_handler : Optional [Callable [[Any ], JSONSerializable ]] = None ,
114
112
indent : int = 0 ,
115
113
):
116
114
self .obj = obj
@@ -153,7 +151,7 @@ def _write(
153
151
ensure_ascii : bool ,
154
152
date_unit : str ,
155
153
iso_dates : bool ,
156
- default_handler : Optional [Callable [[Any ], Serializable ]],
154
+ default_handler : Optional [Callable [[Any ], JSONSerializable ]],
157
155
indent : int ,
158
156
):
159
157
return dumps (
@@ -186,7 +184,7 @@ def _write(
186
184
ensure_ascii : bool ,
187
185
date_unit : str ,
188
186
iso_dates : bool ,
189
- default_handler : Optional [Callable [[Any ], Serializable ]],
187
+ default_handler : Optional [Callable [[Any ], JSONSerializable ]],
190
188
indent : int ,
191
189
):
192
190
if not self .index and orient == "split" :
@@ -233,7 +231,7 @@ def _write(
233
231
ensure_ascii : bool ,
234
232
date_unit : str ,
235
233
iso_dates : bool ,
236
- default_handler : Optional [Callable [[Any ], Serializable ]],
234
+ default_handler : Optional [Callable [[Any ], JSONSerializable ]],
237
235
indent : int ,
238
236
):
239
237
if not self .index and orient == "split" :
@@ -263,7 +261,7 @@ def __init__(
263
261
ensure_ascii : bool ,
264
262
date_unit : str ,
265
263
index : bool ,
266
- default_handler : Optional [Callable [[Any ], Serializable ]] = None ,
264
+ default_handler : Optional [Callable [[Any ], JSONSerializable ]] = None ,
267
265
indent : int = 0 ,
268
266
):
269
267
"""
0 commit comments