Skip to content

Commit 3125430

Browse files
committed
Troubleshoot doctest
1 parent cd8728f commit 3125430

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

pandas/_libs/properties.pyx

+23
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,26 @@ cdef class AxisProperty:
6464

6565
def __set__(self, obj, value):
6666
obj._set_axis(self.axis, value)
67+
68+
69+
cdef class ClassProperty:
70+
"""
71+
Property-like that can be accessed on the class and not just on an instance.
72+
"""
73+
74+
cdef readonly:
75+
object func, name, __doc__
76+
77+
def __init__(self, func):
78+
self.func = func
79+
self.name = name
80+
self.__doc__ = doc
81+
82+
def __get__(self, obj, typ):
83+
return self.func(obj)
84+
85+
def __set__(self, obj, value):
86+
raise AttributeError("Can't set attribute")
87+
88+
89+
class_property = ClassProperty

pandas/core/dtypes/base.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from pandas._typing import DtypeObj
1010
from pandas.errors import AbstractMethodError
11+
from pandas._libs.properties import class_property
1112

1213
from pandas.core.dtypes.generic import ABCDataFrame, ABCIndexClass, ABCSeries
1314

@@ -168,7 +169,7 @@ def kind(self) -> str:
168169
"""
169170
return "O"
170171

171-
@property
172+
@class_property
172173
def name(self) -> str:
173174
"""
174175
A string identifying the data type.

0 commit comments

Comments
 (0)