External imports can be ignored due to local files or folders with the same name
- Dominant language
- Python
- Stars
- 7.5k
- Forks
- 424
- PR merge metrics
- No merged PRs in 30d
Description
`pipreqs` excludes the names of all directories below the target path and all `.py` files (without the `.py`) from the list of imports it reports. Sometimes this can exclude actual external imports. For example, you might have a package hierarchy like:
```
my_awesome_parser/
__init__.py
module.py
util/
__init__.py
yaml.py
```
and `my_awesome_parser.module` might import `yaml` as provided by `PyYaml` but the `yaml.py` in `my_awesome_parser/util` will cause `pipreqs` to exclude `yaml` from its report.
It would require added complexity to handle this case, and I think you could make an argument that a project where this happens is poorly structured, so the best way to address this might be to put a note in the documentation explaining the current behavior. It took me a bit of debugging to figure out why `PyYaml` was not being reported as a requirement for a project I was working with (in my case, it was actually a directory of config files named "yaml" inside of the package, not something intended to be imported). Otherwise there would need to be a mechanism for telling `pipreqs` which directories and `.py` files were valid top-level imports.
Contributor guide
Research direction
Start by reviewing pipreqs' existing documentation and the import-exclusion behavior described in the issue. Reproduce the example with a local yaml.py file or yaml directory, then document that local names can hide external imports and explain the current limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100