PyCG icon indicating copy to clipboard operation
PyCG copied to clipboard

can't get complete call graph

Open Mryanhehe opened this issue 3 years ago • 1 comments

I do a Test and find pycg will generate uncomplete call graph. 微信截图_20220105162917. First , the code of /test1/init.py is as following:

class People():

    def __init__(self) -> None:
        pass

    def returnPeople(self):
        p = People()
        return p

    def talk(self):
        print("hello")

the code of /test2/main.py is as following:

import sys
sys.path.append(r"/mnt/c/Users/79102/Desktop/project/pyPJ/pycgTest")
from thirdLibrary.test1 import People
p1 = People()
p2 = p1.returnPeople()
p2.talk()

The abode can code can run , and print("hello") Then i run pycg , throw all python files into it , get the following result

{
    "test1": [],
    "test1.People.__init__": [],
    "test1.People.returnPeople": [
        "test1.People.__init__"
    ],
    "test1.People.talk": [
        "<builtin>.print"
    ],
    "<builtin>.print": [],
    "test2.main": [
        "thirdLibrary.test1.People",
        "sys.path.append"
    ],
    "sys.path.append": [],
    "thirdLibrary.test1.People": [],
    "test2": []
}

Pycg don't process p1.returnPeople() ,and get incompletecall graph. When i modify the code of /test2/main.py

class People():
    def __init__(self) -> None:
        pass

    def returnPeople(self):
        p = People()
        return p

    def talk(self):
        print("hello")
p1 = People()
p2 = p1.returnPeople()
p2.talk()

I want to get the same result , but the result is as following :

{
    "test2.main": [
        "test2.main.People.returnPeople",
        "test2.main.People.__init__",
        "test2.main.People.talk"
    ],
    "test2.main.People.__init__": [],
    "test2.main.People.returnPeople": [
        "test2.main.People.__init__"
    ],
    "test2.main.People.talk": [
        "<builtin>.print"
    ],
    "<builtin>.print": []
}

The latter is the correct result . When i debug pycg and find the the Intermediate definition of both is the ame , so i think maybe there is a matter with processing definition . I think it would be critical when parsing multiple files.

Mryanhehe avatar Jan 05 '22 08:01 Mryanhehe

You should spend more time learning English.

AllenSun1024 avatar Jan 13 '22 09:01 AllenSun1024

Closing due to archival of repository.

vitsalis avatar Nov 26 '23 07:11 vitsalis