Closed lemon24 closed 2 years ago
Played with it; nice idea, but it seems like too much work.
... especially because in-module-component wildcards aren't supported (e.g. can't match reader.*_utils
).
For reader a list of human-readable rules would likely be enough; I expect it might be useful for larger projects with lots of contributors of different experience levels.
Some things I played with:
[importlinter]
root_package = reader
contract_types =
forbidden: contracts.ForbiddenWildcardContract
independence: contracts.IndependenceWildcardContract
[importlinter:contract:api-no-private-modules]
name = reader does not import from private modules
type = forbidden
importer = reader
imported = reader._*
[importlinter:contract:utils-independent]
name = reader.*_utils should be independent
type = independence
modules =
reader.*_utils
[importlinter:contract:xxx]
name = xxx
type = independence
modules =
reader._parser
reader._storage
reader._update
Also, the _parser/_storage/_update one creates what I think is a false alarm: _update depends on the other two for type checking purposes only (if TYPE_CHECKING: import ...
); it can be fixed in code with Protocols/ABCs, but that way lies Java (interfaces with exactly one class implementing them) ... I guess I would have to do that if I was type checking tests.
https://import-linter.readthedocs.io/en/stable/readme.html