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

Method ismethod

Lib/test/test_pyclbr.py:85–99  ·  view source on GitHub ↗
(oclass, obj, name)

Source from the content-addressed store, hash-verified

83 dict = pyclbr.readmodule_ex(moduleName)
84
85 def ismethod(oclass, obj, name):
86 classdict = oclass.__dict__
87 if isinstance(obj, MethodType):
88 # could be a classmethod
89 if (not isinstance(classdict[name], ClassMethodType) or
90 obj.__self__ is not oclass):
91 return False
92 elif not isinstance(obj, FunctionType):
93 return False
94
95 objname = obj.__name__
96 if objname.startswith("__") and not objname.endswith("__"):
97 if stripped_typename := oclass.__name__.lstrip('_'):
98 objname = f"_{stripped_typename}{objname}"
99 return objname == name
100
101 # Make sure the toplevel functions and classes are the same.
102 for name, value in dict.items():

Callers 3

_is_bound_methodFunction · 0.80
describeFunction · 0.80
_find_linenoMethod · 0.80

Calls 3

startswithMethod · 0.45
endswithMethod · 0.45
lstripMethod · 0.45

Tested by

no test coverage detected