Skip to content

Commit 31fdfff

Browse files
committed
CLN: Use set_module decorator
1 parent 7bf6660 commit 31fdfff

39 files changed

+90
-96
lines changed

.github/workflows/code-checks.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ jobs:
5757
run: sudo apt-get update && sudo apt-get install -y libegl1 libopengl0
5858

5959
- name: Run doctests
60+
env:
61+
PANDAS_SET_MODULE_DUNDER: 0
6062
run: cd ci && ./code_checks.sh doctests
6163
if: ${{ steps.build.outcome == 'success' && always() }}
6264

pandas/_libs/interval.pyx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,6 @@ cdef class Interval(IntervalMixin):
445445
>>> interval.closed
446446
'left'
447447
"""
448-
__module__ = "pandas"
449448

450449
def __init__(self, left, right, str closed="right"):
451450
# note: it is faster to just do these checks than to use a special

pandas/_libs/missing.pyx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ class NAType(C_NAType):
394394
True
395395
"""
396396
__module__ = "pandas.api.typing"
397-
398397
_instance = None
399398

400399
def __new__(cls, *args, **kwargs):

pandas/_libs/tslibs/nattype.pyx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ class NaTType(_NaT):
371371
0 2023-01-01
372372
1 NaT
373373
"""
374-
375374
__module__ = "pandas.api.typing"
376375

377376
def __new__(cls):

pandas/_libs/tslibs/np_datetime.pyx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,6 @@ class OutOfBoundsDatetime(ValueError):
193193
at position 0
194194
"""
195195
__module__ = "pandas.errors"
196-
pass
197196

198197

199198
class OutOfBoundsTimedelta(ValueError):
@@ -213,9 +212,8 @@ class OutOfBoundsTimedelta(ValueError):
213212
OutOfBoundsTimedelta: Cannot cast 139999 days 00:00:00
214213
to unit='ns' without overflow.
215214
"""
216-
__module__ = "pandas.errors"
217215
# Timedelta analogue to OutOfBoundsDatetime
218-
pass
216+
__module__ = "pandas.errors"
219217

220218

221219
cdef get_implementation_bounds(

pandas/_libs/tslibs/offsets.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ from pandas._libs.tslibs.ccalendar import (
4747
int_to_weekday,
4848
weekday_to_int,
4949
)
50+
from pandas.util._decorators import set_module
5051
from pandas.util._exceptions import find_stack_level
5152

5253
from pandas._libs.tslibs.ccalendar cimport (
@@ -1695,6 +1696,7 @@ class OffsetMeta(type):
16951696

16961697

16971698
# TODO: figure out a way to use a metaclass with a cdef class
1699+
@set_module("pandas")
16981700
class DateOffset(RelativeDeltaOffset, metaclass=OffsetMeta):
16991701
"""
17001702
Standard kind of date increment used for a date range.
@@ -1822,8 +1824,6 @@ class DateOffset(RelativeDeltaOffset, metaclass=OffsetMeta):
18221824
>>> ts + pd.DateOffset(hour=8)
18231825
Timestamp('2017-01-01 08:10:11')
18241826
"""
1825-
__module__ = "pandas"
1826-
18271827
def __setattr__(self, name, value):
18281828
raise AttributeError("DateOffset objects are immutable.")
18291829

pandas/_libs/tslibs/period.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1626,12 +1626,12 @@ DIFFERENT_FREQ = ("Input has different freq={other_freq} "
16261626
"from {cls}(freq={own_freq})")
16271627

16281628

1629+
@set_module("pandas.errors")
16291630
class IncompatibleFrequency(TypeError):
16301631
"""
16311632
Raised when trying to compare or operate between Periods with different
16321633
frequencies.
16331634
"""
1634-
__module__ = "pandas.errors"
16351635
pass
16361636

16371637

pandas/core/apply.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@
2929
)
3030
from pandas.compat._optional import import_optional_dependency
3131
from pandas.errors import SpecificationError
32-
from pandas.util._decorators import cache_readonly
32+
from pandas.util._decorators import (
33+
cache_readonly,
34+
set_module,
35+
)
3336

3437
from pandas.core.dtypes.cast import is_nested_object
3538
from pandas.core.dtypes.common import (
@@ -75,6 +78,7 @@
7578
ResType: TypeAlias = dict[int, Any]
7679

7780

81+
@set_module("pandas.api.executors")
7882
class BaseExecutionEngine(abc.ABC):
7983
"""
8084
Base class for execution engines for map and apply methods.
@@ -88,8 +92,6 @@ class BaseExecutionEngine(abc.ABC):
8892
simply runs the code with the Python interpreter and pandas.
8993
"""
9094

91-
__module__ = "pandas.api.executors"
92-
9395
@staticmethod
9496
@abc.abstractmethod
9597
def map(

pandas/core/arrays/arrow/array.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636
PYARROW_MIN_VERSION,
3737
)
3838
from pandas.errors import Pandas4Warning
39-
from pandas.util._decorators import doc
39+
from pandas.util._decorators import (
40+
doc,
41+
set_module,
42+
)
4043
from pandas.util._exceptions import find_stack_level
4144

4245
from pandas.core.dtypes.cast import (
@@ -242,6 +245,7 @@ def to_pyarrow_type(
242245
return None
243246

244247

248+
@set_module("pandas.arrays")
245249
class ArrowExtensionArray(
246250
OpsMixin,
247251
ExtensionArraySupportsAnyAll,
@@ -297,8 +301,6 @@ class ArrowExtensionArray(
297301
Length: 3, dtype: int64[pyarrow]
298302
""" # noqa: E501 (http link too long)
299303

300-
__module__ = "pandas.arrays"
301-
302304
_pa_array: pa.ChunkedArray
303305
_dtype: ArrowDtype
304306

pandas/core/arrays/base.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from pandas.errors import AbstractMethodError
3232
from pandas.util._decorators import (
3333
cache_readonly,
34+
set_module,
3435
)
3536
from pandas.util._validators import (
3637
validate_bool_kwarg,
@@ -106,6 +107,7 @@
106107
_extension_array_shared_docs: dict[str, str] = {}
107108

108109

110+
@set_module("pandas.api.extensions")
109111
class ExtensionArray:
110112
"""
111113
Abstract base class for custom 1-D array types.
@@ -257,8 +259,6 @@ class ExtensionArray:
257259
https://github.com/pandas-dev/pandas/blob/main/pandas/tests/extension/list/array.py
258260
"""
259261

260-
__module__ = "pandas.api.extensions"
261-
262262
# '_typ' is for pandas.core.dtypes.generic.ABCExtensionArray.
263263
# Don't override this.
264264
_typ = "extension"
@@ -2804,6 +2804,7 @@ def _add_logical_ops(cls) -> None:
28042804
setattr(cls, "__rxor__", cls._create_logical_method(roperator.rxor))
28052805

28062806

2807+
@set_module("pandas.api.extensions")
28072808
class ExtensionScalarOpsMixin(ExtensionOpsMixin):
28082809
"""
28092810
A mixin for defining ops on an ExtensionArray.
@@ -2830,8 +2831,6 @@ class ExtensionScalarOpsMixin(ExtensionOpsMixin):
28302831
with NumPy arrays.
28312832
"""
28322833

2833-
__module__ = "pandas.api.extensions"
2834-
28352834
@classmethod
28362835
def _create_method(cls, op, coerce_to_dtype: bool = True, result_dtype=None):
28372836
"""

0 commit comments

Comments
 (0)