For my next "goal" with pants (pun intended :wink:...
# general
p
For my next "goal" with pants (pun intended 😉), I need to replace an old Makefile lint target that uses some ugly
find ... | xargs -0 cat | grep ...
commands to ensure that certain python modules do not import others. The purpose is to prevent circular dependencies, or to make sure that a client lib does not accidentally depend on server libs that don't get released. So, are there any pants goodies to help with circular dependency linting?
2
w
While I've personally never used it, I think someone made (or worked on) a plugin for
import-linter
https://github.com/pantsbuild/pants/issues/15247
h
This longstanding issue is relevant: https://github.com/pantsbuild/pants/issues/13393
b
Which is getting a PR soon!
I mean it's already in PR, lol
🚀 1
p
Hmm. That's backwards from how I was thinking about the import rules. It provides an allow-list approach, but I was thinking in terms of a disallow-list.
w
@proud-dentist-22844 Would
import-linter
(https://pypi.org/project/import-linter/) solve your problems? Curious if there is extra value in trying to get it running with pants, after the PR is merged
p
The contract modelling of
import-linter
sounds like just the thing, but I would rather have something that just reuses
pants
dependency graph instead of re-doing all of that work.
b
@proud-dentist-22844 PR is still open. Your voice matters 😉
1
Also @curved-television-6568 is totally a homie 😉
🙏 1
c
The syntax will use specs, so a disallow list will be totally valid. Circular deps not so much though…
🤔 1
@proud-dentist-22844 lets see how much inspiration we can draw from import linter. The stuff that possibly doesn't fit within the “visibility” work can be deferred to a another feature.
👍 2
p
Oh! After staring at a diagram of dependencies that I made (manually some time ago, before I found pants), I think I see how I can reverse how I was thinking about things. The current grep-based lint does: This module should not import any of these other modules. Visibility would say: This module is
<private>
which implicitly prevents the other module from importing it.
💯 1
1
Ah ha! I forgot about
regex-lint
. That gave me a way to re-implement the current Makefile's (ugly) dependency linting while I wait for
visibility
to be available. 😄
👍 1
❤️ 1