13
13
# limitations under the License.
14
14
15
15
# Pandas Extension Types
16
+ from __future__ import annotations
16
17
17
18
import numbers
18
19
import re
19
- from typing import Union
20
20
21
21
import numpy as np
22
22
import pandas as pd
@@ -38,7 +38,7 @@ class PandasBSONDtype(ExtensionDtype):
38
38
def name (self ) -> str :
39
39
return f"bson_{ self .__class__ .__name__ } "
40
40
41
- def __from_arrow__ (self , array : Union [ pa .Array , pa .ChunkedArray ] ) -> ExtensionArray :
41
+ def __from_arrow__ (self , array : pa .Array | pa .ChunkedArray ) -> ExtensionArray :
42
42
chunks = [array ] if isinstance (array , pa .Array ) else array .chunks
43
43
44
44
arr_type = self .construct_array_type ()
@@ -204,7 +204,7 @@ def name(self) -> str:
204
204
return f"bson_{ self .type .__name__ } [{ self .subtype } ]"
205
205
206
206
@classmethod
207
- def construct_array_type (cls ) -> type [" PandasBinaryArray" ]:
207
+ def construct_array_type (cls ) -> type [PandasBinaryArray ]:
208
208
return PandasBinaryArray
209
209
210
210
@classmethod
@@ -242,7 +242,7 @@ class PandasObjectId(PandasBSONDtype):
242
242
type = ObjectId
243
243
244
244
@classmethod
245
- def construct_array_type (cls ) -> type [" PandasObjectIdArray" ]:
245
+ def construct_array_type (cls ) -> type [PandasObjectIdArray ]:
246
246
return PandasObjectIdArray
247
247
248
248
@@ -266,7 +266,7 @@ class PandasDecimal128(PandasBSONDtype):
266
266
type = Decimal128
267
267
268
268
@classmethod
269
- def construct_array_type (cls ) -> type [" PandasDecimal128Array" ]:
269
+ def construct_array_type (cls ) -> type [PandasDecimal128Array ]:
270
270
return PandasDecimal128Array
271
271
272
272
@@ -290,7 +290,7 @@ class PandasCode(PandasBSONDtype):
290
290
type = Code
291
291
292
292
@classmethod
293
- def construct_array_type (cls ) -> type [" PandasCodeArray" ]:
293
+ def construct_array_type (cls ) -> type [PandasCodeArray ]:
294
294
return PandasCodeArray
295
295
296
296
0 commit comments