-
-
Notifications
You must be signed in to change notification settings - Fork 672
Description
Is your feature request related to a problem? Please describe.
One should be able to control whether self imports of a module should be ignored.
This is different from the dependencies-closed
option which includes the input targets in the output. A Python module may import (and therefore depend) on itself by having an import of a member from that module or a string literal that would be mapped to that module name. You may want to skip reporting dependencies on the module itself to avoid adding # pants: no-infer-dep
comments.
For example, it is not uncommon to declare a logger name in a Python module in this way:
```
# src/project/console.py
...
logger_name = "src.project.console"
```
which would result in having src/project/console.py
reported as being dependent on src/project/console.py
.
When analyzing the dependency graph using graph-based tools, it is desired to avoid cycles as the expectation is that the dependency graph would be a DAG, and having cycles in the graph (src/project/console.py
depends on itself) will impede the graph analysis.
Describe the solution you'd like
A new flag --python-infer-ignore-self-imports
to control whether these type of dependencies should be ignored.
Describe alternatives you've considered
Adding # pants: no-infer-dep
comments on the undesired lines which may get impractical in a large repo.