MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / isdatadescriptor

Function isdatadescriptor

tools/python-3.11.9-amd64/Lib/inspect.py:330–342  ·  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

(object)

Source from the content-addressed store, hash-verified

328 return hasattr(tp, "__get__") and not hasattr(tp, "__set__")
329
330def isdatadescriptor(object):
331 """Return true if the object is a data descriptor.
332
333 Data descriptors have a __set__ or a __delete__ attribute. Examples are
334 properties (defined in Python) and getsets and members (defined in C).
335 Typically, data descriptors will also have __name__ and __doc__ attributes
336 (properties, getsets, and members have both of these attributes), but this
337 is not guaranteed."""
338 if isclass(object) or ismethod(object) or isfunction(object):
339 # mutual exclusion
340 return False
341 tp = type(object)
342 return hasattr(tp, "__set__") or hasattr(tp, "__delete__")
343
344if hasattr(types, 'MemberDescriptorType'):
345 # CPython and equivalent

Callers 1

_finddocFunction · 0.85

Calls 4

isclassFunction · 0.85
ismethodFunction · 0.85
isfunctionFunction · 0.85
typeClass · 0.50

Tested by

no test coverage detected