|
|
|
|
|
by claytonjy
668 days ago
|
|
Looks interesting, but I'm having a hard time understanding what this does that isn't covered by the ruff rules checking for uses of private functions or classes. It seems you can define an extra level of who's allowed to import what...but why would I want to add that on top rather than using standard conventions? Why would I want to let foo import baz, but not let bar import baz? |
|
In large codebases you can have a problem where people randomly import things from different locations leading to a host of issues including circular import issues.
For example someone finds a convenient helper function in "my_thing.foo.bar.helpers" and imports it but you don't want that dependency between those modules and the helper function was not intended to be used outside of that module.
In Python this problem is especially severe because there is no native module encapsulation mechanism other than a weak conventio of using the underscore prefix.
A tool like this helps you enforce "intentional" module boundaries so modules can't randomly reach into each other to import things. You will be forced to consider an intentional modular design where the helpers that are needed by many things are separated out and other things are allowed to import from it.