Skip to content

Commit d8f80de

Browse files
committed
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
1 parent 2f53d18 commit d8f80de

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

pandas/_libs/missing.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,9 @@ class NAType(C_NAType):
375375
>>> True | pd.NA
376376
True
377377
"""
378+
__module__ = "pandas"
378379

379380
_instance = None
380-
__module__ = "pandas"
381381

382382
def __new__(cls, *args, **kwargs):
383383
if NAType._instance is None:

pandas/_libs/tslibs/nattype.pyx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ class NaTType(_NaT):
372372
1 NaT
373373
"""
374374

375+
__module__ = "pandas"
376+
375377
def __new__(cls):
376378
cdef _NaT base
377379

@@ -1828,11 +1830,7 @@ default 'raise'
18281830
@property
18291831
def tzinfo(self) -> None:
18301832
return None
1831-
1832-
@property
1833-
def __module__(self) -> str:
1834-
return "pandas"
1835-
1833+
18361834
def as_unit(self, str unit, bint round_ok=True) -> "NaTType":
18371835
"""
18381836
Convert the underlying int64 representation to the given unit.
@@ -1872,7 +1870,6 @@ default 'raise'
18721870

18731871

18741872
c_NaT = NaTType() # C-visible
1875-
c_NaT.__module__ = "pandas"
18761873
NaT = c_NaT # Python-visible
18771874

18781875

0 commit comments

Comments
 (0)