-
Notifications
You must be signed in to change notification settings - Fork 52
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
Added support for extended interpolations for .ini files. #121
base: master
Are you sure you want to change the base?
Conversation
Thanks for this - I hadn't come across INI file interpolation before. This seems like an elegant solution but I want to think about whether or not it adds unnecessary complexity.
Are you aware that Import Linter does now have wildcard support for ignored imports? I'd be interested to know whether or not adding that to other fields (e.g. |
Yes, I saw that in the documentation, though it wasn't working for other configuration options. It would definitely be nice to define groups of modules using wild cards. A lot of projects developed by large teams could benefit from rules like:
Having a wildcard that can extend to subpackages could also be beneficial. Without it, it is too easy to miss, say |
Agreed. This is how forbidden contracts already behave - from the docs: "Descendants of each module will be checked - so if mypackage.one is forbidden from importing mypackage.two, then mypackage.one.blue will be forbidden from importing mypackage.two.green." Of course, we'd need to implement wildcard support first! Regarding the contract you describe above, I do wonder if we're stretching the limits of the original intention of forbidden contracts, which are meant to be fairly simple. It might be worth considering viewing this as a layered architecture instead. That way you can use a layers contract, which allows you to list containers so you don't need to keep defining the containing packages:
Alternatively, you could consider creating directories to correspond to the two-tier architecture implied by that forbidden contract, i.e.
Then the layers contract would simply be:
|
Just to mention that I would also like the ability to add groups |
Could you go into a bit more detail? Would be helpful to see some examples. Thanks! |
I had a use case consisting of a rather complicated project with a lot of legacy code that we are trying to organize. Both the
layers
andindependence
contracts would have to have moreignores
that would be practical. It seemed to be easier to define groups of modules explicitly (or ideally with wild cards) and enforce architecture that way.This PR configures
.ini
files to use theconfigparser.ExtendedInterpolation()
. Unfortunately, I don't thinktoml
has built in support for interpolations, and I'm not really sure how each package manager will set up the ini parser when parsingsetup.cfg
, so I had no reliable way add the feature when handling those formats.Tests pass
Docs Build