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

Feature request: minimum imports #218

Open sbrugman opened 6 months ago

sbrugman commented 6 months ago

Prematurely generalization by moving functions to different modules (e.g. common, utils) can lead to a convoluted codebases. This can lead to global chaos, especially in mono-repos.

It would be interesting to be able to require a minimum number of imports between certain modules, for instance, utility functions at the top level of the module need to be imported by at least two submodules. (Two+ links in the import graph)

(If you think in terms of number of links, then forbidden is just the special case where max=0)

seddonym commented 6 months ago

Interesting idea! So are you thinking this would be a new contract type?

One option for this would be to implement it as a custom contract to begin with. It could even be published as its own PyPI package and have a different maintainer, if someone is interested.