Skip to content

Commit e1983fa

Browse files
ENH: set __module__ on remaining Dtype classes (#62335)
1 parent f6565fc commit e1983fa

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

pandas/core/arrays/boolean.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
lib,
1515
missing as libmissing,
1616
)
17+
from pandas.util._decorators import set_module
1718

1819
from pandas.core.dtypes.common import is_list_like
1920
from pandas.core.dtypes.dtypes import register_extension_dtype
@@ -39,6 +40,7 @@
3940

4041

4142
@register_extension_dtype
43+
@set_module("pandas")
4244
class BooleanDtype(BaseMaskedDtype):
4345
"""
4446
Extension dtype for boolean data.

pandas/core/arrays/floating.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import numpy as np
1010

11+
from pandas.util._decorators import set_module
12+
1113
from pandas.core.dtypes.base import register_extension_dtype
1214
from pandas.core.dtypes.common import is_float_dtype
1315

@@ -168,13 +170,15 @@ class FloatingArray(NumericArray):
168170

169171

170172
@register_extension_dtype
173+
@set_module("pandas")
171174
class Float32Dtype(FloatingDtype):
172175
type = np.float32
173176
name: ClassVar[str] = "Float32"
174177
__doc__ = _dtype_docstring.format(dtype="float32")
175178

176179

177180
@register_extension_dtype
181+
@set_module("pandas")
178182
class Float64Dtype(FloatingDtype):
179183
type = np.float64
180184
name: ClassVar[str] = "Float64"

pandas/core/arrays/integer.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
import numpy as np
1010

11+
from pandas.util._decorators import set_module
12+
1113
from pandas.core.dtypes.base import register_extension_dtype
1214
from pandas.core.dtypes.common import is_integer_dtype
1315

@@ -218,55 +220,63 @@ class IntegerArray(NumericArray):
218220

219221

220222
@register_extension_dtype
223+
@set_module("pandas")
221224
class Int8Dtype(IntegerDtype):
222225
type = np.int8
223226
name: ClassVar[str] = "Int8"
224227
__doc__ = _dtype_docstring.format(dtype="int8")
225228

226229

227230
@register_extension_dtype
231+
@set_module("pandas")
228232
class Int16Dtype(IntegerDtype):
229233
type = np.int16
230234
name: ClassVar[str] = "Int16"
231235
__doc__ = _dtype_docstring.format(dtype="int16")
232236

233237

234238
@register_extension_dtype
239+
@set_module("pandas")
235240
class Int32Dtype(IntegerDtype):
236241
type = np.int32
237242
name: ClassVar[str] = "Int32"
238243
__doc__ = _dtype_docstring.format(dtype="int32")
239244

240245

241246
@register_extension_dtype
247+
@set_module("pandas")
242248
class Int64Dtype(IntegerDtype):
243249
type = np.int64
244250
name: ClassVar[str] = "Int64"
245251
__doc__ = _dtype_docstring.format(dtype="int64")
246252

247253

248254
@register_extension_dtype
255+
@set_module("pandas")
249256
class UInt8Dtype(IntegerDtype):
250257
type = np.uint8
251258
name: ClassVar[str] = "UInt8"
252259
__doc__ = _dtype_docstring.format(dtype="uint8")
253260

254261

255262
@register_extension_dtype
263+
@set_module("pandas")
256264
class UInt16Dtype(IntegerDtype):
257265
type = np.uint16
258266
name: ClassVar[str] = "UInt16"
259267
__doc__ = _dtype_docstring.format(dtype="uint16")
260268

261269

262270
@register_extension_dtype
271+
@set_module("pandas")
263272
class UInt32Dtype(IntegerDtype):
264273
type = np.uint32
265274
name: ClassVar[str] = "UInt32"
266275
__doc__ = _dtype_docstring.format(dtype="uint32")
267276

268277

269278
@register_extension_dtype
279+
@set_module("pandas")
270280
class UInt64Dtype(IntegerDtype):
271281
type = np.uint64
272282
name: ClassVar[str] = "UInt64"

pandas/tests/api/test_api.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,23 @@ def test_util_in_top_level(self):
412412
def test_set_module():
413413
assert pd.DataFrame.__module__ == "pandas"
414414
assert pd.CategoricalDtype.__module__ == "pandas"
415+
assert pd.DatetimeTZDtype.__module__ == "pandas"
415416
assert pd.PeriodDtype.__module__ == "pandas"
416417
assert pd.IntervalDtype.__module__ == "pandas"
417418
assert pd.SparseDtype.__module__ == "pandas"
418419
assert pd.ArrowDtype.__module__ == "pandas"
419420
assert pd.StringDtype.__module__ == "pandas"
421+
assert pd.BooleanDtype.__module__ == "pandas"
422+
assert pd.Int8Dtype.__module__ == "pandas"
423+
assert pd.Int16Dtype.__module__ == "pandas"
424+
assert pd.Int32Dtype.__module__ == "pandas"
425+
assert pd.Int64Dtype.__module__ == "pandas"
426+
assert pd.UInt8Dtype.__module__ == "pandas"
427+
assert pd.UInt16Dtype.__module__ == "pandas"
428+
assert pd.UInt32Dtype.__module__ == "pandas"
429+
assert pd.UInt64Dtype.__module__ == "pandas"
430+
assert pd.Float32Dtype.__module__ == "pandas"
431+
assert pd.Float64Dtype.__module__ == "pandas"
420432
assert pd.Index.__module__ == "pandas"
421433
assert pd.CategoricalIndex.__module__ == "pandas"
422434
assert pd.DatetimeIndex.__module__ == "pandas"

0 commit comments

Comments
 (0)