Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable to explicitly disallow import of certain external dependencies #535

Open
janbernloehr opened this issue Jan 12, 2025 · 3 comments
Open
Labels
enhancement New feature or request

Comments

@janbernloehr
Copy link

janbernloehr commented Jan 12, 2025

We often have the usecase where for a certain package we want to disallow imports of an external package foo.

Now to please tach check-external we would have to add all other packages to the dependencies which is cumbersome and requires frequent changes. Instead, we would like to explicitly model the forbidden external import of foo only.

@emdoyle
Copy link
Member

emdoyle commented Jan 17, 2025

Hi @janbernloehr , thanks for raising this. Can you provide a few more details about your use case?

It sounds like you are maintaining multiple Python packages in your repo, are these built and released separately, or do they share an environment?

My assumption about listing dependencies for each package was that every external package would need to be listed there anyway, is this not the case? I might be misunderstanding the workaround you are describing.

@janbernloehr
Copy link
Author

Our usecase is that we have two packages foo and bar in our repo. We would like to prohibit foo from importing tensorflow and bar from importing torch. Instead of having a list of all external dependencies of foo we would rather just add tensorflow to the list of prohibited imports.

@samuelhwilliams
Copy link

I also have this use case and would find it really valuable. In lieu of tach supporting it we might end up using import-linter or similar.

In our case, we want to limit the ability to import from eg sqlalchemy in anything except one of the modules in our codebase, so that all database access goes through a central place.

@emdoyle emdoyle added the enhancement New feature or request label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants