Skip to content

Commit ca82618

Browse files
authored
Clean up typing for pandas GenericDtype (#1601)
* clean up common GenericDtype Signed-off-by: cosmicBboy <[email protected]> * clean up common GenericDtype Signed-off-by: cosmicBboy <[email protected]> --------- Signed-off-by: cosmicBboy <[email protected]>
1 parent cf09ae2 commit ca82618

File tree

1 file changed

+48
-87
lines changed

1 file changed

+48
-87
lines changed

pandera/typing/common.py

+48-87
Original file line numberDiff line numberDiff line change
@@ -55,95 +55,56 @@
5555
BOOL = pandas_engine.BOOL #: ``"str"`` numpy dtype
5656

5757

58-
try:
58+
if pandas_engine.GEOPANDAS_INSTALLED:
5959
Geometry = pandas_engine.Geometry # : ``"geometry"`` geopandas dtype
60-
GEOPANDAS_INSTALLED = True
61-
except AttributeError:
62-
GEOPANDAS_INSTALLED = False
63-
64-
if GEOPANDAS_INSTALLED:
65-
GenericDtype = TypeVar( # type: ignore
66-
"GenericDtype",
67-
bound=Union[
68-
bool,
69-
int,
70-
str,
71-
float,
72-
pd.core.dtypes.base.ExtensionDtype,
73-
Bool,
74-
Date,
75-
DateTime,
76-
Decimal,
77-
Timedelta,
78-
Category,
79-
Float,
80-
Float16,
81-
Float32,
82-
Float64,
83-
Int,
84-
Int8,
85-
Int16,
86-
Int32,
87-
Int64,
88-
UInt8,
89-
UInt16,
90-
UInt32,
91-
UInt64,
92-
INT8,
93-
INT16,
94-
INT32,
95-
INT64,
96-
UINT8,
97-
UINT16,
98-
UINT32,
99-
UINT64,
100-
Object,
101-
String,
102-
STRING,
103-
Geometry,
104-
],
105-
)
10660
else:
107-
GenericDtype = TypeVar( # type: ignore
108-
"GenericDtype",
109-
bound=Union[
110-
bool,
111-
int,
112-
str,
113-
float,
114-
pd.core.dtypes.base.ExtensionDtype,
115-
Bool,
116-
Date,
117-
DateTime,
118-
Decimal,
119-
Timedelta,
120-
Category,
121-
Float,
122-
Float16,
123-
Float32,
124-
Float64,
125-
Int,
126-
Int8,
127-
Int16,
128-
Int32,
129-
Int64,
130-
UInt8,
131-
UInt16,
132-
UInt32,
133-
UInt64,
134-
INT8,
135-
INT16,
136-
INT32,
137-
INT64,
138-
UINT8,
139-
UINT16,
140-
UINT32,
141-
UINT64,
142-
Object,
143-
String,
144-
STRING,
145-
],
146-
)
61+
62+
class Geometry: # type: ignore [no-redef]
63+
# pylint: disable=too-few-public-methods
64+
... # stub Geometry type
65+
66+
67+
GenericDtype = TypeVar( # type: ignore
68+
"GenericDtype",
69+
bound=Union[
70+
bool,
71+
int,
72+
str,
73+
float,
74+
pd.core.dtypes.base.ExtensionDtype,
75+
Bool,
76+
Date,
77+
DateTime,
78+
Decimal,
79+
Timedelta,
80+
Category,
81+
Float,
82+
Float16,
83+
Float32,
84+
Float64,
85+
Int,
86+
Int8,
87+
Int16,
88+
Int32,
89+
Int64,
90+
UInt8,
91+
UInt16,
92+
UInt32,
93+
UInt64,
94+
INT8,
95+
INT16,
96+
INT32,
97+
INT64,
98+
UINT8,
99+
UINT16,
100+
UINT32,
101+
UINT64,
102+
Object,
103+
String,
104+
STRING,
105+
Geometry,
106+
],
107+
)
147108

148109
DataFrameModel = TypeVar("DataFrameModel", bound="DataFrameModel") # type: ignore
149110

0 commit comments

Comments
 (0)