22from io import StringIO
33from itertools import islice
44import os
5- from typing import Any , Callable , Dict , List , Optional , Type , Union
5+ from typing import Any , Callable , Optional , Type
66
77import numpy as np
88
1313from pandas .core .dtypes .common import ensure_str , is_period_dtype
1414
1515from pandas import DataFrame , MultiIndex , Series , compat , isna , to_datetime
16- from pandas ._typing import Scalar
16+ from pandas ._typing import JSONSerializable
1717from pandas .core .reshape .concat import concat
1818
1919from pandas .io .common import (
3434
3535TABLE_SCHEMA_VERSION = "0.20.0"
3636
37- Serializable = Union [Scalar , List , Dict ]
38-
3937
4038# interface to/from
4139def to_json (
@@ -46,7 +44,7 @@ def to_json(
4644 double_precision : int = 10 ,
4745 force_ascii : bool = True ,
4846 date_unit : str = "ms" ,
49- default_handler : Optional [Callable [[Any ], Serializable ]] = None ,
47+ default_handler : Optional [Callable [[Any ], JSONSerializable ]] = None ,
5048 lines : bool = False ,
5149 compression : Optional [str ] = "infer" ,
5250 index : bool = True ,
@@ -110,7 +108,7 @@ def __init__(
110108 ensure_ascii : bool ,
111109 date_unit : str ,
112110 index : bool ,
113- default_handler : Optional [Callable [[Any ], Serializable ]] = None ,
111+ default_handler : Optional [Callable [[Any ], JSONSerializable ]] = None ,
114112 indent : int = 0 ,
115113 ):
116114 self .obj = obj
@@ -153,7 +151,7 @@ def _write(
153151 ensure_ascii : bool ,
154152 date_unit : str ,
155153 iso_dates : bool ,
156- default_handler : Optional [Callable [[Any ], Serializable ]],
154+ default_handler : Optional [Callable [[Any ], JSONSerializable ]],
157155 indent : int ,
158156 ):
159157 return dumps (
@@ -186,7 +184,7 @@ def _write(
186184 ensure_ascii : bool ,
187185 date_unit : str ,
188186 iso_dates : bool ,
189- default_handler : Optional [Callable [[Any ], Serializable ]],
187+ default_handler : Optional [Callable [[Any ], JSONSerializable ]],
190188 indent : int ,
191189 ):
192190 if not self .index and orient == "split" :
@@ -233,7 +231,7 @@ def _write(
233231 ensure_ascii : bool ,
234232 date_unit : str ,
235233 iso_dates : bool ,
236- default_handler : Optional [Callable [[Any ], Serializable ]],
234+ default_handler : Optional [Callable [[Any ], JSONSerializable ]],
237235 indent : int ,
238236 ):
239237 if not self .index and orient == "split" :
@@ -263,7 +261,7 @@ def __init__(
263261 ensure_ascii : bool ,
264262 date_unit : str ,
265263 index : bool ,
266- default_handler : Optional [Callable [[Any ], Serializable ]] = None ,
264+ default_handler : Optional [Callable [[Any ], JSONSerializable ]] = None ,
267265 indent : int = 0 ,
268266 ):
269267 """
0 commit comments