Comments (8)
Thanks for reporting the issue! This might indeed be casued by the special use case of the class, because I tried testing pycg in the aforementioned case where child
is a simple function, and I could not reproduce the issue. PyCG could resolve the from library.parent import child
import statement and succesfully build the call graph.
from pycg.
Thank you for your prompt response. I was just about to edit this issue. We do a little filtering of the tree based on the parent library
and this caused me to miss it.
It actually does have library.other_class.process: [child_classes.child]
within the tree but we were expecting the full library path of child
, something like ``library.other_class.process: [library.parent.child_classes.child]`. Is this because of the relative import?
I've updated the initial issue to reflect this discovery. The weird thing is that in our library we use relative imports like this everywhere (as most libs do) and in some cases relative imports do include the full path. Not sure why this case is different.
from pycg.
This seems to be a weird behaviour indeed.
But still I can't reproduce the issue. When I run the code described above, the namespace is produced corretly and includes the library.parent
prefix.
If in the little filtering that you describe you change the location of the file we would expect PyCG to depict a namespace of the new location.
from pycg.
Hmm, well one thing that we've noticed is that modules that appear in the tree as partial paths of the parent library
are those that are called from within a submodule like from .stuff import this
. While the case that I've abstracted from to propose this issue doesn't result from a relative import, I'm wondering if they are connected somehow.
Here is a clear case:
# stuff/__init__.py
from .file1 import that
from .file2 import this
# stuff/file2.py
from .file1 import that
this():
something = that()
...
In this case it would show "library.stuff.file1.this": ["file2.that"]
rather than library.stuff.file2.that
.
from pycg.
Hmm I also find that PyCG does this partial path stuff if it's initiated from the root of the library vs. above it, even when the list of .pys
are passed in as absolute paths?
from pycg.
Just want to add a bit of info from correcting the partial module paths that PyCG gives. We found that switching the imports from the file pwdata/pipeline/tests/test_pipeline.py
from:
from pwdata.pipeline.memoizer import Memoizer, create_tree
to
from pwdata.pipeline.memoizer.memoize import Memoizer
from pwdata.pipeline.memoizer.cg_tree import create_tree
Would resolve the issues where we only got:
'pwdata.pipeline.tests.test_pipeline.test_cg_tree': ['<builtin>.len',
'cg_gen.create_tree',
'memoize.Memoizer']
but wanted to have (and correctly get after the above absolute import fix):
'pwdata.pipeline.tests.test_pipeline.test_cg_tree': ['<builtin>.len',
'pwdata.pipeline.memoizer.memoize.Memoizer',
'pwdata.pipeline.memoizer.cg_tree.create_tree']
from pycg.
@gdrosos Just wondering if you were able to see my most recent responses and had any thoughts? If it might make it easier I could make a minimal working example of this in a repo.
from pycg.
Closing due to archival of repository.
from pycg.
Related Issues (20)
- Broken link HOT 1
- What tool have you used to generate the figures from JSON/FASTEN? HOT 1
- Can it be used to generate static backward slice? HOT 1
- what is the meaning of NEXT_MEHOD and ITER_METHOD? HOT 1
- list definition creation causes an infinite loop in the post processor HOT 1
- make test occur a error HOT 1
- Can PyCG optimize to flow sensitive? HOT 5
- PyCG fails when parsing files whose names are used in init file declarations HOT 1
- how to analyse cg of __init__.py HOT 2
- Possible to have option to exclude builtin functions? HOT 1
- Not being able to run PyCG from source due to circular import(?) HOT 2
- analysis does not follow explicit super()-calls HOT 2
- Add class def in addition to MRO HOT 1
- Does pycg work in colab? HOT 1
- PyCG can't support the analysis of function pointers in a call graph. HOT 1
- Ignore built-in functions, numpy, torch... HOT 2
- Detected non-deterministic results under various configurations HOT 3
- Handling posonlyargs HOT 2
- Install of `0.0.7` failing in GitHub actions HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pycg.