From 2f53d18521cd11c15c4f2d461a1764a753453fc5 Mon Sep 17 00:00:00 2001 From: meet-vasita Date: Thu, 11 Sep 2025 01:06:29 +0530 Subject: [PATCH 1/2] Fix NaT and NA docs: Set __module__ to 'pandas' to prevent wrong alias message Set __module__ = 'pandas' on NaTType and NAType to fix incorrect autodoc 'alias of' messages. Closes #62185. --- pandas/_libs/missing.pyx | 1 + pandas/_libs/tslibs/nattype.pyx | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pandas/_libs/missing.pyx b/pandas/_libs/missing.pyx index c7f905c4d0be0..955480c6bf511 100644 --- a/pandas/_libs/missing.pyx +++ b/pandas/_libs/missing.pyx @@ -377,6 +377,7 @@ class NAType(C_NAType): """ _instance = None + __module__ = "pandas" def __new__(cls, *args, **kwargs): if NAType._instance is None: diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 2657b1b9d197b..126052e4227c5 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -1828,7 +1828,11 @@ default 'raise' @property def tzinfo(self) -> None: return None - + + @property + def __module__(self) -> str: + return "pandas" + def as_unit(self, str unit, bint round_ok=True) -> "NaTType": """ Convert the underlying int64 representation to the given unit. @@ -1868,6 +1872,7 @@ default 'raise' c_NaT = NaTType() # C-visible +c_NaT.__module__ = "pandas" NaT = c_NaT # Python-visible From d8f80dea02ecedaeb7761c1e5b17bc8a36c6cf55 Mon Sep 17 00:00:00 2001 From: meet-vasita Date: Thu, 11 Sep 2025 02:01:46 +0530 Subject: [PATCH 2/2] DOC: Set __module__ attribute for NA and NaT classes Fixes Sphinx autodoc showing circular 'alias of' references for pandas.NA and pandas.NaT by explicitly setting their __module__ attribute to 'pandas'. Closes #62185 --- pandas/_libs/missing.pyx | 2 +- pandas/_libs/tslibs/nattype.pyx | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/pandas/_libs/missing.pyx b/pandas/_libs/missing.pyx index 955480c6bf511..4a824e0fb2461 100644 --- a/pandas/_libs/missing.pyx +++ b/pandas/_libs/missing.pyx @@ -375,9 +375,9 @@ class NAType(C_NAType): >>> True | pd.NA True """ + __module__ = "pandas" _instance = None - __module__ = "pandas" def __new__(cls, *args, **kwargs): if NAType._instance is None: diff --git a/pandas/_libs/tslibs/nattype.pyx b/pandas/_libs/tslibs/nattype.pyx index 126052e4227c5..3e22c13e37f76 100644 --- a/pandas/_libs/tslibs/nattype.pyx +++ b/pandas/_libs/tslibs/nattype.pyx @@ -372,6 +372,8 @@ class NaTType(_NaT): 1 NaT """ + __module__ = "pandas" + def __new__(cls): cdef _NaT base @@ -1828,11 +1830,7 @@ default 'raise' @property def tzinfo(self) -> None: return None - - @property - def __module__(self) -> str: - return "pandas" - + def as_unit(self, str unit, bint round_ok=True) -> "NaTType": """ Convert the underlying int64 representation to the given unit. @@ -1872,7 +1870,6 @@ default 'raise' c_NaT = NaTType() # C-visible -c_NaT.__module__ = "pandas" NaT = c_NaT # Python-visible