PyCG icon indicating copy to clipboard operation
PyCG copied to clipboard

pycg can‘t find the real function

Open Gzxl opened this issue 3 years ago • 3 comments

repo:https://github.com/PaddlePaddle/PaddleClas cmd :pycg --package ppclas $(find ppclas -type f -name "*.py") -o ppclas.json error: funciton:ppcls/arch/backbone/base/theseus_layer.py is subclass paddle.nn.Layer the function train is from nn.Layer but the ppclas.json not show this message e.g.:

image

Gzxl avatar Apr 12 '22 09:04 Gzxl

PyCG can only analyze the code that it has been given. It can't know what the parent class contains and therefore cannot identify that particular call.

vitsalis avatar Apr 12 '22 09:04 vitsalis

I still have some problems, as you have said, we shouldn‘t get ppadle.nn.Layer.train but at the top function :engine.py: def train() PyCG get ppadle.nn.Layer.train e.g.: image

Gzxl avatar Apr 12 '22 09:04 Gzxl

This happens because PyCG tries to do some basic inference about what was the external function that was called based on the imports. More specifically, when PyCG sees something along the lines of

from xyz.pkg import smth
smth()

it can understand that there was a call to the smth() function inside the xyz.pkg module. However, we can't go further than that because we do not have the code for xyz.pkg.

vitsalis avatar Apr 12 '22 10:04 vitsalis