File tree 4 files changed +12
-42
lines changed
4 files changed +12
-42
lines changed Original file line number Diff line number Diff line change 7
7
"""
8
8
import copy
9
9
import itertools
10
+ from typing import Type
10
11
11
12
import numpy as np
12
13
import pyarrow as pa
@@ -29,14 +30,7 @@ class ArrowBoolDtype(ExtensionDtype):
29
30
na_value = pa .NULL
30
31
31
32
@classmethod
32
- def construct_from_string (cls , string ):
33
- if string == cls .name :
34
- return cls ()
35
- else :
36
- raise TypeError (f"Cannot construct a '{ cls .__name__ } ' from '{ string } '" )
37
-
38
- @classmethod
39
- def construct_array_type (cls ):
33
+ def construct_array_type (cls ) -> Type ["ArrowBoolArray" ]:
40
34
"""
41
35
Return the array type associated with this dtype.
42
36
@@ -46,7 +40,8 @@ def construct_array_type(cls):
46
40
"""
47
41
return ArrowBoolArray
48
42
49
- def _is_boolean (self ):
43
+ @property
44
+ def _is_boolean (self ) -> bool :
50
45
return True
51
46
52
47
@@ -59,14 +54,7 @@ class ArrowStringDtype(ExtensionDtype):
59
54
na_value = pa .NULL
60
55
61
56
@classmethod
62
- def construct_from_string (cls , string ):
63
- if string == cls .name :
64
- return cls ()
65
- else :
66
- raise TypeError (f"Cannot construct a '{ cls } ' from '{ string } '" )
67
-
68
- @classmethod
69
- def construct_array_type (cls ):
57
+ def construct_array_type (cls ) -> Type ["ArrowStringArray" ]:
70
58
"""
71
59
Return the array type associated with this dtype.
72
60
Original file line number Diff line number Diff line change 2
2
import numbers
3
3
import random
4
4
import sys
5
+ from typing import Type
5
6
6
7
import numpy as np
7
8
@@ -26,7 +27,7 @@ def __repr__(self) -> str:
26
27
return f"DecimalDtype(context={ self .context } )"
27
28
28
29
@classmethod
29
- def construct_array_type (cls ):
30
+ def construct_array_type (cls ) -> Type [ "DecimalArray" ] :
30
31
"""
31
32
Return the array type associated with this dtype.
32
33
@@ -36,15 +37,8 @@ def construct_array_type(cls):
36
37
"""
37
38
return DecimalArray
38
39
39
- @classmethod
40
- def construct_from_string (cls , string ):
41
- if string == cls .name :
42
- return cls ()
43
- else :
44
- raise TypeError (f"Cannot construct a '{ cls .__name__ } ' from '{ string } '" )
45
-
46
40
@property
47
- def _is_numeric (self ):
41
+ def _is_numeric (self ) -> bool :
48
42
return True
49
43
50
44
Original file line number Diff line number Diff line change 16
16
import random
17
17
import string
18
18
import sys
19
+ from typing import Type
19
20
20
21
import numpy as np
21
22
@@ -29,7 +30,7 @@ class JSONDtype(ExtensionDtype):
29
30
na_value = UserDict ()
30
31
31
32
@classmethod
32
- def construct_array_type (cls ):
33
+ def construct_array_type (cls ) -> Type [ "JSONArray" ] :
33
34
"""
34
35
Return the array type associated with this dtype.
35
36
@@ -39,13 +40,6 @@ def construct_array_type(cls):
39
40
"""
40
41
return JSONArray
41
42
42
- @classmethod
43
- def construct_from_string (cls , string ):
44
- if string == cls .name :
45
- return cls ()
46
- else :
47
- raise TypeError (f"Cannot construct a '{ cls .__name__ } ' from '{ string } '" )
48
-
49
43
50
44
class JSONArray (ExtensionArray ):
51
45
dtype = JSONDtype ()
Original file line number Diff line number Diff line change 6
6
import numbers
7
7
import random
8
8
import string
9
+ from typing import Type
9
10
10
11
import numpy as np
11
12
@@ -21,7 +22,7 @@ class ListDtype(ExtensionDtype):
21
22
na_value = np .nan
22
23
23
24
@classmethod
24
- def construct_array_type (cls ):
25
+ def construct_array_type (cls ) -> Type [ "ListArray" ] :
25
26
"""
26
27
Return the array type associated with this dtype.
27
28
@@ -31,13 +32,6 @@ def construct_array_type(cls):
31
32
"""
32
33
return ListArray
33
34
34
- @classmethod
35
- def construct_from_string (cls , string ):
36
- if string == cls .name :
37
- return cls ()
38
- else :
39
- raise TypeError (f"Cannot construct a '{ cls } ' from '{ string } '" )
40
-
41
35
42
36
class ListArray (ExtensionArray ):
43
37
dtype = ListDtype ()
You can’t perform that action at this time.
0 commit comments