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

Question: Do not allow any imports #223

Closed kkirsche closed 4 months ago

kkirsche commented 4 months ago

👋 Thanks for the great library!

I was wondering if I was missing something, but is there a simple contract type to simply say this module should not import any other module? For example, a module of constants? This avoids the need for having to define all the modules that are within a project.

Thanks, and sorry if this is a dumb question. I appreciate your time and help.

seddonym commented 4 months ago

Hi! Not a dumb question at all!

There is an open ticket for that and indeed a pull request submitted by @sbrugman. I have left comments but unfortunately it seems to have gone stale.

In the meantime you could look at a layers contract with that module being the lowest layer. You'd have to explicitly list the other sibling modules though. You could also do it with not too much code as a custom contract. Or - even simpler - just grep for the work import in a completely custom script!