seddonym / import-linter

Import Linter allows you to define and enforce rules for the internal and external imports within your Python project.
https://import-linter.readthedocs.io/
BSD 2-Clause "Simplified" License
664 stars 45 forks source link

Hyphen & underscore insensitive package resolution #210

Open dlqqq opened 8 months ago

dlqqq commented 8 months ago

This is an awesome tool! I have a small feature suggestion.

I was using hyphens instead of underscores in my package name, which kept giving me "package not found" errors. I almost gave up on this tool before noticing that the root_package field needs to exactly match the package name.

pip is insensitive to whether hyphens or underscores are used. It would be awesome if import-linter did the same.

seddonym commented 8 months ago

Thanks for the issue! I think you're right that the documentation is potentially confusing. When the docs say this should contain 'the name of the Python package to validate', it's unclear whether it should be the pip-installable name on pypi (e.g. import-linter) or the name of the importable package (e.g. importlinter). In fact, it's the second, and has nothing to do with pip.

For that reason I don't think we should change the behaviour (if we were analyzing Import Linter itself, neither import-linter nor import_linter would work). Instead we should just clarify what we mean by package name.

Do you think if the docs clarified this in this section that would have helped you?