Skip to content

Commit b093091

Browse files
committed
Refinements
1 parent 6ceda9c commit b093091

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

pandas/_config/config.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,6 @@ def __init__(self, d: dict[str, Any], prefix: str = "") -> None:
413413
object.__setattr__(self, "prefix", prefix)
414414

415415
def __setattr__(self, key: str, val: Any) -> None:
416-
if key == "__module__":
417-
# Need to be able to set __module__ to pandas for pandas.options
418-
super().__setattr__(key, val)
419-
return
420416
prefix = object.__getattribute__(self, "prefix")
421417
if prefix:
422418
prefix += "."
@@ -447,7 +443,8 @@ def __dir__(self) -> list[str]:
447443

448444

449445
options = DictWrapper(_global_config)
450-
options.__module__ = "pandas"
446+
# DictWrapper defines a custom setattr
447+
object.__setattr__(options, "__module__", "pandas")
451448

452449
#
453450
# Functions for use by pandas developers, in addition to User - api

pandas/_libs/interval.pyx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ cdef class Interval(IntervalMixin):
382382
>>> year_2017.length
383383
Timedelta('365 days 00:00:00')
384384
"""
385+
__module__ = "pandas"
385386
_typ = "interval"
386387
__array_priority__ = 1000
387388

pandas/core/dtypes/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def is_datetime64tz_dtype(arr_or_dtype) -> bool:
359359
>>> is_datetime64tz_dtype(pd.DatetimeIndex([1, 2, 3], tz="US/Eastern"))
360360
True
361361
362-
>>> from pandas.api.types import DatetimeTZDtype
362+
>>> from pandas import DatetimeTZDtype
363363
>>> dtype = DatetimeTZDtype("ns", tz="US/Eastern")
364364
>>> s = pd.Series([], dtype=dtype)
365365
>>> is_datetime64tz_dtype(dtype)

pandas/tests/api/test_api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,8 @@ def test_attributes_module(module_name):
643643
# Explicit exceptions
644644
or ("Dtype" in name and obj.__module__ == "pandas")
645645
or (name == "Categorical" and obj.__module__ == "pandas")
646-
# TODO: Can't seem to change __module__
646+
# Setting __module__ on a cdef class has no effect
647+
# https://github.com/cython/cython/issues/7231
647648
or name == "Interval"
648649
)
649650
]

0 commit comments

Comments
 (0)