Support wildcards for modules in forbidden contracts
Hi there!
I found an issue I wasn't able to resolve. I browed through the closed tickets but couldn't find a match there, so I created this ticket.
I use the import-linter (v2.0) with Django and all my Django apps live in apps/. When I try to use a wildcard, the contract never fails. If I put the module explicitly, it works, thus fails.
Works:
[[tool.importlinter.contracts]]
name = "Config is intependent of everything else"
type = "forbidden"
source_modules = ["apps.config"]
forbidden_modules = [
"apps.account",
]
Not working:
[[tool.importlinter.contracts]]
name = "Config is intependent of everything else"
type = "forbidden"
source_modules = ["apps.config"]
forbidden_modules = [
"apps.*",
]
Am I missing something? Thanks for your help!
Best from Cologne
Ronny
Hi Ronny, thanks for the issue.
It's because wildcards aren't supported for those fields, they're only supported (at present) for ignored_imports.
It's got nothing to do with TOML, so I've renamed this issue accordingly.
I'd be happy to support someone on a pull request if they wanted to add this. There is actually a pull request open for adding wildcard support for another contract type (independence), which I've left some feedback on, but it seems to have stalled. Let me know if you're interested in taking it on.
Hi @seddonym
thanks for the quick reply!
Neither me nor my colleague @fbinz got that this feature is just not implemented. Since I feel not too comfortable with linter code, I could offer a PR for the docs to emphasis this fact.
What do you say?
Best
Ronny
Sounds good, thanks!
@seddonym I think this has been implemented now? Shall we close the issue?
Yes! Thank you.