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

Support wildcards for modules in forbidden contracts #232

Open
GitRon opened this issue Aug 26, 2024 · 3 comments
Open

Support wildcards for modules in forbidden contracts #232

GitRon opened this issue Aug 26, 2024 · 3 comments

Comments

@GitRon
Copy link
Contributor

GitRon commented Aug 26, 2024

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

@seddonym seddonym changed the title Wildcards not working in TOML Support wildcards for modules in forbidden contracts Aug 27, 2024
@seddonym
Copy link
Owner

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.

@GitRon
Copy link
Contributor Author

GitRon commented Aug 27, 2024

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

@seddonym
Copy link
Owner

Sounds good, thanks!

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

2 participants