class A:
def m1():
// in a.m1
pass
class B(A):
def m2():
// in b.m2
Parsing above code shall give me following info - class names - B, base -> A, method names -> a.m1, b.m2
I have looked into Jedi, but I don't see any Api to extract above information.
You might find the standard library
pyclbrmodule useful to determine classes, methods, and parent classes in a module. here's its docsIts
_mainfunction should help with some example usage and help get you to a solution (Runningpython3 -m inspect pyclbrwill show you the source code of thepyclbrmodule so you can see_main).Here's the output of the
_mainfunction being run againstpyclbritself:You'll probably need to access the
superattributes of the Class andreadmodule_exreturns to determine the base class info you want to output.Pros:
inspectrequires one to (so, in theory, you're safer running it against code you don't trust)Cons: