Skip to content
This repository has been archived by the owner on Nov 26, 2023. It is now read-only.

can't get complete call graph #20

Closed
Mryanhehe opened this issue Jan 5, 2022 · 2 comments
Closed

can't get complete call graph #20

Mryanhehe opened this issue Jan 5, 2022 · 2 comments

Comments

@Mryanhehe
Copy link
Contributor

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.

@AllenSun1024
Copy link

You should spend more time learning English.

@vitsalis
Copy link
Owner

Closing due to archival of repository.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants