-
Notifications
You must be signed in to change notification settings - Fork 664
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
Fix relative imports in args rule #4216
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
corubba
requested review from
ssbarnea and
Qalthos
and removed request for
a team
June 7, 2024 23:47
I give up, no idea how to make the linters happy(er). |
Just realized this is the same problem as in #4208 , and used the provided reproduce-playbook from the issue to confirm this PR fixes it too. |
ssbarnea
approved these changes
Jun 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The
args
rule loads modules used in/by tasks using pythonsimportlib
. When doing so it uses the ansible full-qualified collection name (fqcn), which works fine if the module only uses absolute imports. But if the to-be-loaded module uses relative imports, it breaks because the fqcn is different from the python qualified name (local.testcollection.module_with_relative_import
vsansible_collections.local.testcollection.plugins.modules.module_with_relative_import
). As importlib and python have no idea about ansible collections, it will look for the wrong packages/modules, which manifests on the user-side in warnings like this:It is looking for a module (or rather package) named
local
because that is the parent-package in the fqcn, while the actual parent isplugins
. #2813 isn't really clear on why the fqcn was used.For testing, I added a whole local collection, which is a first in the repo and may be a bit "too much". Any advice for a better solution is appreciated.
I initially ran into this issue with the
containers.podman.podman_container
module, in case you want an actual example from the wild.Fixes #4208