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

why can't you forbid subpackages of external modules? #182

Open
dpinol opened this issue Jul 27, 2023 · 3 comments
Open

why can't you forbid subpackages of external modules? #182

dpinol opened this issue Jul 27, 2023 · 3 comments

Comments

@dpinol
Copy link

dpinol commented Jul 27, 2023

[tool.importlinter]
include_external_packages = true
root_packages = ["scserver", "scweb", "test"]

[[tool.importlinter.contracts]]
name = "kk"
forbidden_modules = ["pytest_check.check"]
source_modules = ["test"]
type = "forbidden"

With this config I get:
Invalid forbidden module pytest_check.check: subpackages of external packages are not valid.

@seddonym
Copy link
Owner

You should be able to fix this by adding pytest_check as one of the root packages. Alternatively, change pytest_check.check to just pytest_check.

The reason for this is because Import Linter analyses a graph of the imports between different modules. If you don't include pytest_check as a root package then it will just be added as a single node pytest_check in the graph.

Hope that solves your problem!

@pwalsh

This comment was marked as off-topic.

@seddonym
Copy link
Owner

seddonym commented Sep 5, 2023

@pwalsh - I've opened a separate ticket for your question, see link above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants