PyCG
PyCG copied to clipboard
can't get complete call graph
I do a Test and find pycg will generate uncomplete call graph.
.
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.
You should spend more time learning English.
Closing due to archival of repository.