See all callers of all methods of a class

I'm aware that I can use 'Find Usages' to find what's calling a method on a class.
Is there a way of doing this for all methods on a given class? (or indeed all methods in file) 

Use Case: I'm trying to refactor a god class, that should almost certainly be several classes. It would be nice to be able to see what subset of god class methods, the classes that interact with it use. It seems like PyCharm has done the hard bit of this, but doesn't let me scale it up.  

I'm using PyCharm 2016.1.2

Comment actions Permalink

This is possible, but you have to deal with abstraction otherwise Pycharm doesn't know the method in question belongs to your specific class. AKA - Type Hinting

Any instance of that method being called in an abstraction layer which does not have type hinting will not be found.


#The class which has the method you're searching for.
class Inst(object):
    def mymethod(self):

#not the class your looking for, but it too has a method of the same name.
class SomethingElse(object):
    def mymethod(self):

#Option 1 -- Assert hinting
def foo(inst):
    assert isinstance(inst, Inst)

#Option 2 --  docstring hinting
def bar(inst):

    :param inst: 
    :type inst: Inst 

Please sign in to leave a comment.