Call hierarchy for Python


I am using method to get the callees of a function.

However, I'm getting some weird results.

For this code snippet:

class A:
def __init__(self):

def foo(self, x):
return x

class B(A):
def foo(self, x):
return D()

class D(A):
def foo(self, x):
b = B()
return A()

class C(A):
def foo(self, x):
y = D()
return self

def driver():
x = A()
i = 10
while i > 0:
x =

I want to know the callees of According to my observation, there should be only two callees of

  1. and
  2. A.__init__

But PyStaticCallHierarchyUtil#getCallees returns 5 callees for I also checked in the PyCharm IDE, same results there as well.

Clearly, the type of b in b = B() is class B.

def foo(self, x):
b = B()
return A()

So, how come,, and are on the callee list of

I would really appreciate any insight on this topic.


Hi, it is a bug. The fix is ready and should land in 2021.3.1, I've created a ticket in our bug tracker to track the status