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

Add only those sys.paths which contain an ansible_collections directory path #322

Merged
merged 6 commits into from
Aug 29, 2023
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/ansible_compat/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,14 @@ def warning(
def _add_sys_path_to_collection_paths(self) -> None:
"""Add the sys.path to the collection paths."""
if not self.isolated and self.config.collections_scan_sys_path:
self.config.collections_paths.extend(sys.path) # pylint: disable=E1101
for path in sys.path:
if (
path not in self.config.collections_paths
and Path(Path(path) / "ansible_collections").is_dir()
audgirka marked this conversation as resolved.
Show resolved Hide resolved
):
self.config.collections_paths.append( # noqa: PERF401 pylint: disable=E1101
path,
)

def load_collections(self) -> None:
"""Load collection data."""
Expand Down