pipreqs icon indicating copy to clipboard operation
pipreqs copied to clipboard

External imports can be ignored due to local files or folders with the same name

Open wshanks opened this issue 8 years ago • 1 comments

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.

wshanks avatar May 24 '17 19:05 wshanks

I've experienced the same issue. Python is very bad in handling name collisions in general, but with pipreqs, it gets more dangerous, as we now have to release a new version just because of the omitted requirement. This behavior should be described in some warning text box on the front page.

F-I-D-O avatar Oct 01 '19 13:10 F-I-D-O