Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/code-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ jobs:
run: sudo apt-get update && sudo apt-get install -y libegl1 libopengl0

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

Expand Down
1 change: 0 additions & 1 deletion pandas/_libs/interval.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,6 @@ cdef class Interval(IntervalMixin):
>>> interval.closed
'left'
"""
__module__ = "pandas"

def __init__(self, left, right, str closed="right"):
# note: it is faster to just do these checks than to use a special
Expand Down
1 change: 0 additions & 1 deletion pandas/_libs/missing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ class NAType(C_NAType):
True
"""
__module__ = "pandas.api.typing"

_instance = None

def __new__(cls, *args, **kwargs):
Expand Down
1 change: 0 additions & 1 deletion pandas/_libs/tslibs/nattype.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ class NaTType(_NaT):
0 2023-01-01
1 NaT
"""

__module__ = "pandas.api.typing"

def __new__(cls):
Expand Down
4 changes: 1 addition & 3 deletions pandas/_libs/tslibs/np_datetime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ class OutOfBoundsDatetime(ValueError):
at position 0
"""
__module__ = "pandas.errors"
pass


class OutOfBoundsTimedelta(ValueError):
Expand All @@ -213,9 +212,8 @@ class OutOfBoundsTimedelta(ValueError):
OutOfBoundsTimedelta: Cannot cast 139999 days 00:00:00
to unit='ns' without overflow.
"""
__module__ = "pandas.errors"
# Timedelta analogue to OutOfBoundsDatetime
pass
__module__ = "pandas.errors"


cdef get_implementation_bounds(
Expand Down
4 changes: 2 additions & 2 deletions pandas/_libs/tslibs/offsets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ from pandas._libs.tslibs.ccalendar import (
int_to_weekday,
weekday_to_int,
)
from pandas.util._decorators import set_module
from pandas.util._exceptions import find_stack_level

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


# TODO: figure out a way to use a metaclass with a cdef class
@set_module("pandas")
class DateOffset(RelativeDeltaOffset, metaclass=OffsetMeta):
"""
Standard kind of date increment used for a date range.
Expand Down Expand Up @@ -1822,8 +1824,6 @@ class DateOffset(RelativeDeltaOffset, metaclass=OffsetMeta):
>>> ts + pd.DateOffset(hour=8)
Timestamp('2017-01-01 08:10:11')
"""
__module__ = "pandas"

def __setattr__(self, name, value):
raise AttributeError("DateOffset objects are immutable.")

Expand Down
2 changes: 1 addition & 1 deletion pandas/_libs/tslibs/period.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1626,12 +1626,12 @@ DIFFERENT_FREQ = ("Input has different freq={other_freq} "
"from {cls}(freq={own_freq})")


@set_module("pandas.errors")
class IncompatibleFrequency(TypeError):
"""
Raised when trying to compare or operate between Periods with different
frequencies.
"""
__module__ = "pandas.errors"
pass


Expand Down
8 changes: 5 additions & 3 deletions pandas/core/apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@
)
from pandas.compat._optional import import_optional_dependency
from pandas.errors import SpecificationError
from pandas.util._decorators import cache_readonly
from pandas.util._decorators import (
cache_readonly,
set_module,
)

from pandas.core.dtypes.cast import is_nested_object
from pandas.core.dtypes.common import (
Expand Down Expand Up @@ -75,6 +78,7 @@
ResType: TypeAlias = dict[int, Any]


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

__module__ = "pandas.api.executors"

@staticmethod
@abc.abstractmethod
def map(
Expand Down
8 changes: 5 additions & 3 deletions pandas/core/arrays/arrow/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@
PYARROW_MIN_VERSION,
)
from pandas.errors import Pandas4Warning
from pandas.util._decorators import doc
from pandas.util._decorators import (
doc,
set_module,
)
from pandas.util._exceptions import find_stack_level

from pandas.core.dtypes.cast import (
Expand Down Expand Up @@ -241,6 +244,7 @@ def to_pyarrow_type(
return None


@set_module("pandas.arrays")
class ArrowExtensionArray(
OpsMixin,
ExtensionArraySupportsAnyAll,
Expand Down Expand Up @@ -296,8 +300,6 @@ class ArrowExtensionArray(
Length: 3, dtype: int64[pyarrow]
""" # noqa: E501 (http link too long)

__module__ = "pandas.arrays"

_pa_array: pa.ChunkedArray
_dtype: ArrowDtype

Expand Down
7 changes: 3 additions & 4 deletions pandas/core/arrays/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from pandas.errors import AbstractMethodError
from pandas.util._decorators import (
cache_readonly,
set_module,
)
from pandas.util._validators import (
validate_bool_kwarg,
Expand Down Expand Up @@ -105,6 +106,7 @@
_extension_array_shared_docs: dict[str, str] = {}


@set_module("pandas.api.extensions")
class ExtensionArray:
"""
Abstract base class for custom 1-D array types.
Expand Down Expand Up @@ -256,8 +258,6 @@ class ExtensionArray:
https://github.com/pandas-dev/pandas/blob/main/pandas/tests/extension/list/array.py
"""

__module__ = "pandas.api.extensions"

# '_typ' is for pandas.core.dtypes.generic.ABCExtensionArray.
# Don't override this.
_typ = "extension"
Expand Down Expand Up @@ -2788,6 +2788,7 @@ def _add_logical_ops(cls) -> None:
setattr(cls, "__rxor__", cls._create_logical_method(roperator.rxor))


@set_module("pandas.api.extensions")
class ExtensionScalarOpsMixin(ExtensionOpsMixin):
"""
A mixin for defining ops on an ExtensionArray.
Expand All @@ -2814,8 +2815,6 @@ class ExtensionScalarOpsMixin(ExtensionOpsMixin):
with NumPy arrays.
"""

__module__ = "pandas.api.extensions"

@classmethod
def _create_method(cls, op, coerce_to_dtype: bool = True, result_dtype=None):
"""
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/arrays/boolean.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ def coerce_to_array(
return values, mask


@set_module("pandas.arrays")
class BooleanArray(BaseMaskedArray):
"""
Array of boolean (True/False) data with missing values.
Expand Down Expand Up @@ -321,8 +322,6 @@ class BooleanArray(BaseMaskedArray):
Length: 3, dtype: boolean
"""

__module__ = "pandas.arrays"

_TRUE_VALUES = {"True", "TRUE", "true", "1", "1.0"}
_FALSE_VALUES = {"False", "FALSE", "false", "0", "0.0"}

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from pandas._libs.arrays import NDArrayBacked
from pandas.compat.numpy import function as nv
from pandas.errors import Pandas4Warning
from pandas.util._decorators import set_module
from pandas.util._exceptions import find_stack_level
from pandas.util._validators import validate_bool_kwarg

Expand Down Expand Up @@ -245,6 +246,7 @@ def contains(cat, key, container) -> bool:
return any(loc_ in container for loc_ in loc)


@set_module("pandas")
class Categorical(NDArrayBackedExtensionArray, PandasObject, ObjectStringArrayMixin):
"""
Represent a categorical variable in classic R / S-plus fashion.
Expand Down Expand Up @@ -361,8 +363,6 @@ class Categorical(NDArrayBackedExtensionArray, PandasObject, ObjectStringArrayMi
'c'
"""

__module__ = "pandas"

# For comparisons, so that numpy uses our implementation if the compare
# ops, which raise
__array_priority__ = 1000
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
)
from pandas._libs.tslibs.dtypes import abbrev_to_npy_unit
from pandas.errors import PerformanceWarning
from pandas.util._decorators import set_module
from pandas.util._exceptions import find_stack_level
from pandas.util._validators import validate_inclusive

Expand Down Expand Up @@ -171,6 +172,7 @@ def f(self):
return property(f)


@set_module("pandas.arrays")
class DatetimeArray(dtl.TimelikeOps, dtl.DatelikeOps):
"""
Pandas ExtensionArray for tz-naive or tz-aware datetime data.
Expand Down Expand Up @@ -223,8 +225,6 @@ class DatetimeArray(dtl.TimelikeOps, dtl.DatelikeOps):
Length: 2, dtype: datetime64[s]
"""

__module__ = "pandas.arrays"

_typ = "datetimearray"
_internal_fill_value = np.datetime64("NaT", "ns")
_recognized_scalars = (datetime, np.datetime64)
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/arrays/floating.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def _safe_cast(cls, values: np.ndarray, dtype: np.dtype, copy: bool) -> np.ndarr
return values.astype(dtype, copy=copy)


@set_module("pandas.arrays")
class FloatingArray(NumericArray):
"""
Array of floating (optional missing) values.
Expand Down Expand Up @@ -129,8 +130,6 @@ class FloatingArray(NumericArray):
Length: 3, dtype: Float32
"""

__module__ = "pandas.arrays"

_dtype_cls = FloatingDtype


Expand Down
3 changes: 1 addition & 2 deletions pandas/core/arrays/integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def _safe_cast(cls, values: np.ndarray, dtype: np.dtype, copy: bool) -> np.ndarr
) from err


@set_module("pandas.arrays")
class IntegerArray(NumericArray):
"""
Array of integer (optional missing) values.
Expand Down Expand Up @@ -142,8 +143,6 @@ class IntegerArray(NumericArray):
Length: 3, dtype: UInt16
"""

__module__ = "pandas.arrays"

_dtype_cls = IntegerDtype


Expand Down
4 changes: 2 additions & 2 deletions pandas/core/arrays/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
)
from pandas.compat.numpy import function as nv
from pandas.errors import IntCastingNaNError
from pandas.util._decorators import set_module

from pandas.core.dtypes.cast import (
LossySetitemError,
Expand Down Expand Up @@ -176,6 +177,7 @@
"""


@set_module("pandas.arrays")
class IntervalArray(IntervalMixin, ExtensionArray):
"""
Pandas array for interval data that are closed on the same side.
Expand Down Expand Up @@ -243,8 +245,6 @@ class IntervalArray(IntervalMixin, ExtensionArray):
:meth:`IntervalArray.from_breaks`, and :meth:`IntervalArray.from_tuples`.
"""

__module__ = "pandas.arrays"

can_hold_na = True
_na_value = _fill_value = np.nan

Expand Down
3 changes: 2 additions & 1 deletion pandas/core/arrays/numpy_.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from pandas._libs import lib
from pandas._libs.tslibs import is_supported_dtype
from pandas.compat.numpy import function as nv
from pandas.util._decorators import set_module

from pandas.core.dtypes.astype import astype_array
from pandas.core.dtypes.cast import (
Expand Down Expand Up @@ -52,12 +53,12 @@
from pandas.arrays import StringArray


@set_module("pandas.arrays")
class NumpyExtensionArray(
OpsMixin,
NDArrayBackedExtensionArray,
ObjectStringArrayMixin,
):
__module__ = "pandas.arrays"
"""
A pandas ExtensionArray for NumPy data.

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/arrays/period.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
from pandas.util._decorators import (
cache_readonly,
doc,
set_module,
)

from pandas.core.dtypes.common import (
Expand Down Expand Up @@ -120,6 +121,7 @@ def f(self):
return property(f)


@set_module("pandas.arrays")
# error: Definition of "_concat_same_type" in base class "NDArrayBacked" is
# incompatible with definition in base class "ExtensionArray"
class PeriodArray(dtl.DatelikeOps, libperiod.PeriodMixin): # type: ignore[misc]
Expand Down Expand Up @@ -177,8 +179,6 @@ class PeriodArray(dtl.DatelikeOps, libperiod.PeriodMixin): # type: ignore[misc]
Length: 2, dtype: period[D]
"""

__module__ = "pandas.arrays"

# array priority higher than numpy scalars
__array_priority__ = 1000
_typ = "periodarray" # ABCPeriodArray
Expand Down
8 changes: 5 additions & 3 deletions pandas/core/arrays/sparse/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@
from pandas._libs.tslibs import NaT
from pandas.compat.numpy import function as nv
from pandas.errors import PerformanceWarning
from pandas.util._decorators import doc
from pandas.util._decorators import (
doc,
set_module,
)
from pandas.util._exceptions import find_stack_level
from pandas.util._validators import (
validate_bool_kwarg,
Expand Down Expand Up @@ -289,6 +292,7 @@ def _wrap_result(
)


@set_module("pandas.arrays")
class SparseArray(OpsMixin, PandasObject, ExtensionArray):
"""
An ExtensionArray for storing sparse data.
Expand Down Expand Up @@ -370,8 +374,6 @@ class SparseArray(OpsMixin, PandasObject, ExtensionArray):
Indices: array([2, 3], dtype=int32)
"""

__module__ = "pandas.arrays"

_subtyp = "sparse_array" # register ABCSparseArray
_hidden_attrs = PandasObject._hidden_attrs | frozenset([])
_sparse_index: SparseIndex
Expand Down
Loading
Loading