Comments (1)
Hi @robinderat , and thank you for your interest in pydeps.
The behavior you're seeing is (at least partially) an artifact of how the python module system works. The statement from a.b import c
imports and executes modules a
and b
. To see what is going on I've added some print statements to the different files in your example
srv/tmp/../example-project❱ yamldirs example_project
example_project:
__init__.py: print('example_project.__init__.py')
main.py: |
print('main.py')
from example_project.module.submodule import bar
bar()
module:
__init__.py: print('module.__init__.py')
submodule.py: |
print('submodule.py')
def bar():
print('bar()')
return None
running main gives the following:
srv/tmp/../example-project❱ python -m example_project.main
example_project.__init__.py
main.py
module.__init__.py
submodule.py
bar()
it's even more apparent if you run pydeps directly on the main.py
file:
srv/tmp/../example-project❱ pydeps example_project\main.py -T png
Pydeps (must) traverse the modules on the path to check for other import statements, so the graph is technically correct, but I can see how the resulting graph is not maximally useful.
I'm not sure I know how to change pydeps to prune the graph correctly, but there should be enough information in the bytecode
>>> def fn():
... from example_project.module.submodule import bar
... bar()
...
>>> dis.dis(fn)
1 0 RESUME 0
2 2 LOAD_CONST 1 (0)
4 LOAD_CONST 2 (('bar',))
6 IMPORT_NAME 0 (example_project.module.submodule)
8 IMPORT_FROM 1 (bar)
10 STORE_FAST 0 (bar)
12 POP_TOP
I'm always happy to merge a PR that adds this functionality...
from pydeps.
Related Issues (20)
- [Feature Request] Specify module name instead of filename HOT 4
- Resolving relative dependencies? HOT 7
- Support for namespace packages HOT 1
- use of `--externals` results in TypeError: 'Config' object does not support item assignment HOT 1
- --dot-output option is not effective HOT 1
- Support output markdown mermaid HOT 1
- empty result with WARNING: SKIPPING ILLEGAL MODULE_NAME: D:.test.a HOT 2
- Support for specifying more than one `fname`
- 1.12.19: pitest fails in `tests/test_package_names.py::test_find_package_names` unit HOT 2
- `--exclude` option not working HOT 1
- Show only top-level imports HOT 1
- Exclude/include dependencies by filepath HOT 1
- Add type hints HOT 1
- Use of pydeps in CI to reject introduction of new import cycles? HOT 3
- Constrain output geometry / size HOT 2
- pydeps randomly generates compiled pyc files when examine python source file HOT 4
- Support for editable packages / direct_url.json HOT 10
- Different types of imports get disconnected. HOT 3
- Feature Request: Pydeps for pipelines HOT 2
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 pydeps.