MCPcopy Index your code
hub / github.com/RustPython/RustPython / _finddoc

Function _finddoc

Lib/inspect.py:710–769  ·  view source on GitHub ↗
(obj)

Source from the content-addressed store, hash-verified

708 return cls
709
710def _finddoc(obj):
711 if isclass(obj):
712 for base in obj.__mro__:
713 if base is not object:
714 try:
715 doc = base.__doc__
716 except AttributeError:
717 continue
718 if doc is not None:
719 return doc
720 return None
721
722 if ismethod(obj):
723 name = obj.__func__.__name__
724 self = obj.__self__
725 if (isclass(self) and
726 getattr(getattr(self, name, None), '__func__') is obj.__func__):
727 # classmethod
728 cls = self
729 else:
730 cls = self.__class__
731 elif isfunction(obj):
732 name = obj.__name__
733 cls = _findclass(obj)
734 if cls is None or getattr(cls, name) is not obj:
735 return None
736 elif isbuiltin(obj):
737 name = obj.__name__
738 self = obj.__self__
739 if (isclass(self) and
740 self.__qualname__ + '.' + name == obj.__qualname__):
741 # classmethod
742 cls = self
743 else:
744 cls = self.__class__
745 # Should be tested before isdatadescriptor().
746 elif isinstance(obj, property):
747 name = obj.__name__
748 cls = _findclass(obj.fget)
749 if cls is None or getattr(cls, name) is not obj:
750 return None
751 elif ismethoddescriptor(obj) or isdatadescriptor(obj):
752 name = obj.__name__
753 cls = obj.__objclass__
754 if getattr(cls, name) is not obj:
755 return None
756 if ismemberdescriptor(obj):
757 slots = getattr(cls, '__slots__', None)
758 if isinstance(slots, dict) and name in slots:
759 return slots[name]
760 else:
761 return None
762 for base in cls.__mro__:
763 try:
764 doc = getattr(base, name).__doc__
765 except AttributeError:
766 continue
767 if doc is not None:

Callers 1

getdocFunction · 0.70

Calls 10

isclassFunction · 0.85
ismethodFunction · 0.85
getattrFunction · 0.85
isfunctionFunction · 0.85
isbuiltinFunction · 0.85
isinstanceFunction · 0.85
ismethoddescriptorFunction · 0.85
isdatadescriptorFunction · 0.85
ismemberdescriptorFunction · 0.85
_findclassFunction · 0.70

Tested by

no test coverage detected