SoftwareUnderstanding / inspect4py

Static code analysis package for Python repositories
https://inspect4py.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
28 stars 10 forks source link

Distinguish class instantiation calls from regular function calls #357

Closed lazyhope closed 2 years ago

lazyhope commented 2 years ago

In our current implementation, any class instantiation call like MyClass() will be included in generated call list, even though they are not regular function calls. This is because they are both parsed to ast nodes of type ast.Call, and there seems to be no difference between ast nodes generated from classs instantiation calls and regular function calls.

What's more, in the following case:

from outside import unknown
unknown()

It seems impossible for us to tell whether “unknown”is a class or a function call solely from the source code or ast nodes generated from it, as the current inspect4py generates results based on the source code and ast nodes parsed from it, without validating whether the function of a function call exists or not, I cannot find an easy way to solve this issue.

rosafilgueira commented 2 years ago

I have addressed this in my last commit. Now we are already to distinguish them, and not include them (instations calls) in our call list