MCPcopy Index your code
hub / github.com/python/cpython / isdatadescriptor

Function isdatadescriptor

Lib/inspect.py:219–231  ·  view source on GitHub ↗

Return true if the object is a data descriptor. Data descriptors have a __set__ or a __delete__ attribute. Examples are properties (defined in Python) and getsets and members (defined in C). Typically, data descriptors will also have __name__ and __doc__ attributes (properties, get

(object)

Source from the content-addressed store, hash-verified

217 and not hasattr(tp, "__delete__"))
218
219def isdatadescriptor(object):
220 """Return true if the object is a data descriptor.
221
222 Data descriptors have a __set__ or a __delete__ attribute. Examples are
223 properties (defined in Python) and getsets and members (defined in C).
224 Typically, data descriptors will also have __name__ and __doc__ attributes
225 (properties, getsets, and members have both of these attributes), but this
226 is not guaranteed."""
227 if isclass(object) or ismethod(object) or isfunction(object):
228 # mutual exclusion
229 return False
230 tp = type(object)
231 return hasattr(tp, "__set__") or hasattr(tp, "__delete__")
232
233if hasattr(types, 'MemberDescriptorType'):
234 # CPython and equivalent

Callers 1

_finddocFunction · 0.85

Calls 3

isclassFunction · 0.85
ismethodFunction · 0.85
isfunctionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…