Home

Lint your Python architecture.
Import Linter allows you to impose constraints on the imports between your Python modules.
It also provides a browser-based user interface for exploring the architecture of any Python package.
How it works
Let's say your Python project looks like this:
myproject
├── __init__.py
├── blue/
└── green/
After installation, create a file called .importlinter:
# .importlinter
[importlinter]
root_package = myproject
[importlinter:contract:one]
name = Green must not import blue
type = forbidden
source_modules = myproject.green
forbidden_modules = myproject.blue
Then, running lint-imports will error if any modules in myproject.green import from myproject.blue.
That's just a simple example: Import Linter supports lots of different contract types, and you can even create your own!
Contract types
Protected
Prevent modules from being directly imported, except by modules in an allow-list.