https://pantsbuild.org/ logo
#general
Title
# general
w

worried-painter-31382

10/27/2022, 8:48 AM
Is there a way to restrict which in-repo modules are allowed to be imported to different in-repo modules with pants?
We currently use a separate python script to check for this, but it's proven to be a hard problem (dependency inference, anyone 😄) Our usecase 1. Easier to enforce SRP, which junior devs might struggle with 2. Modules can be classified at different risk levels in medical devices, and separating code by strict module depedencies makes us not drown in regulatory assessments
w

wide-midnight-78598

10/27/2022, 10:40 AM
I don't think we can currently, but something like this has come up before. Related? https://github.com/pantsbuild/pants/issues/15247 https://github.com/pantsbuild/pants/issues/13393
w

worried-painter-31382

10/27/2022, 10:52 AM
Yep 👍
p

proud-dentist-22844

10/27/2022, 2:12 PM
A very coarse method that is available today is using regex-lint like this: https://github.com/StackStorm/st2/pull/5778 I look forward to better methods in the future.
w

wide-midnight-78598

10/27/2022, 2:13 PM
Perhaps this is worthy of a GH Discussion topic (if one doesn't exist)? It seems like this comes up a lot, but I haven't fully grokked what each person imagines it might look like. There is also whether this is a python thing vs a cross-backend thing
Having said that, I do something similar - but I don't use tooling to constrain it in python... I just trust people... Or scold them.