(obj)
| 119 | return cls |
| 120 | |
| 121 | def _finddoc(obj): |
| 122 | if inspect.ismethod(obj): |
| 123 | name = obj.__func__.__name__ |
| 124 | self = obj.__self__ |
| 125 | if (inspect.isclass(self) and |
| 126 | getattr(getattr(self, name, None), '__func__') is obj.__func__): |
| 127 | # classmethod |
| 128 | cls = self |
| 129 | else: |
| 130 | cls = self.__class__ |
| 131 | elif inspect.isfunction(obj): |
| 132 | name = obj.__name__ |
| 133 | cls = _findclass(obj) |
| 134 | if cls is None or getattr(cls, name) is not obj: |
| 135 | return None |
| 136 | elif inspect.isbuiltin(obj): |
| 137 | name = obj.__name__ |
| 138 | self = obj.__self__ |
| 139 | if (inspect.isclass(self) and |
| 140 | self.__qualname__ + '.' + name == obj.__qualname__): |
| 141 | # classmethod |
| 142 | cls = self |
| 143 | else: |
| 144 | cls = self.__class__ |
| 145 | # Should be tested before isdatadescriptor(). |
| 146 | elif isinstance(obj, property): |
| 147 | name = obj.__name__ |
| 148 | cls = _findclass(obj.fget) |
| 149 | if cls is None or getattr(cls, name) is not obj: |
| 150 | return None |
| 151 | elif inspect.ismethoddescriptor(obj) or inspect.isdatadescriptor(obj): |
| 152 | name = obj.__name__ |
| 153 | cls = obj.__objclass__ |
| 154 | if getattr(cls, name) is not obj: |
| 155 | return None |
| 156 | if inspect.ismemberdescriptor(obj): |
| 157 | slots = getattr(cls, '__slots__', None) |
| 158 | if isinstance(slots, dict) and name in slots: |
| 159 | return slots[name] |
| 160 | else: |
| 161 | return None |
| 162 | for base in cls.__mro__: |
| 163 | try: |
| 164 | doc = _getowndoc(getattr(base, name)) |
| 165 | except AttributeError: |
| 166 | continue |
| 167 | if doc is not None: |
| 168 | return doc |
| 169 | return None |
| 170 | |
| 171 | def _getowndoc(obj): |
| 172 | """Get the documentation string for an object if it is not |
no test coverage detected