diff options
Diffstat (limited to 'src/ansible_compat')
-rw-r--r-- | src/ansible_compat/__init__.py | 1 | ||||
-rw-r--r-- | src/ansible_compat/config.py | 1 | ||||
-rw-r--r-- | src/ansible_compat/errors.py | 1 | ||||
-rw-r--r-- | src/ansible_compat/loaders.py | 1 | ||||
-rw-r--r-- | src/ansible_compat/ports.py | 1 | ||||
-rw-r--r-- | src/ansible_compat/prerun.py | 1 | ||||
-rw-r--r-- | src/ansible_compat/runtime.py | 29 | ||||
-rw-r--r-- | src/ansible_compat/schema.py | 1 | ||||
-rw-r--r-- | src/ansible_compat/types.py | 1 |
9 files changed, 26 insertions, 11 deletions
diff --git a/src/ansible_compat/__init__.py b/src/ansible_compat/__init__.py index b23c8ca..3c437d4 100644 --- a/src/ansible_compat/__init__.py +++ b/src/ansible_compat/__init__.py @@ -1,4 +1,5 @@ """ansible_compat package.""" + from importlib.metadata import PackageNotFoundError, version try: diff --git a/src/ansible_compat/config.py b/src/ansible_compat/config.py index a0b41b7..6bed01b 100644 --- a/src/ansible_compat/config.py +++ b/src/ansible_compat/config.py @@ -1,4 +1,5 @@ """Store configuration options as a singleton.""" + from __future__ import annotations import ast diff --git a/src/ansible_compat/errors.py b/src/ansible_compat/errors.py index 6369412..25db7c7 100644 --- a/src/ansible_compat/errors.py +++ b/src/ansible_compat/errors.py @@ -1,4 +1,5 @@ """Module to deal with errors.""" + from __future__ import annotations from typing import TYPE_CHECKING, Any diff --git a/src/ansible_compat/loaders.py b/src/ansible_compat/loaders.py index d2ae080..9951094 100644 --- a/src/ansible_compat/loaders.py +++ b/src/ansible_compat/loaders.py @@ -1,4 +1,5 @@ """Utilities for loading various files.""" + from __future__ import annotations from typing import TYPE_CHECKING, Any diff --git a/src/ansible_compat/ports.py b/src/ansible_compat/ports.py index 9c46ae6..bdb9db5 100644 --- a/src/ansible_compat/ports.py +++ b/src/ansible_compat/ports.py @@ -1,4 +1,5 @@ """Portability helpers.""" + from functools import cache, cached_property __all__ = ["cache", "cached_property"] diff --git a/src/ansible_compat/prerun.py b/src/ansible_compat/prerun.py index 6dfa44f..9448269 100644 --- a/src/ansible_compat/prerun.py +++ b/src/ansible_compat/prerun.py @@ -1,4 +1,5 @@ """Utilities for configuring ansible runtime environment.""" + import hashlib import os from pathlib import Path diff --git a/src/ansible_compat/runtime.py b/src/ansible_compat/runtime.py index ad81132..4556b7e 100644 --- a/src/ansible_compat/runtime.py +++ b/src/ansible_compat/runtime.py @@ -1,4 +1,5 @@ """Ansible runtime environment manager.""" + from __future__ import annotations import contextlib @@ -94,11 +95,11 @@ class Plugins: # pylint: disable=too-many-instance-attributes lookup: dict[str, str] = field(init=False) netconf: dict[str, str] = field(init=False) shell: dict[str, str] = field(init=False) - vars: dict[str, str] = field(init=False) # noqa: A003 + vars: dict[str, str] = field(init=False) module: dict[str, str] = field(init=False) strategy: dict[str, str] = field(init=False) test: dict[str, str] = field(init=False) - filter: dict[str, str] = field(init=False) # noqa: A003 + filter: dict[str, str] = field(init=False) role: dict[str, str] = field(init=False) keyword: dict[str, str] = field(init=False) @@ -589,6 +590,7 @@ class Runtime: _logger.error(result.stderr) raise AnsibleCommandError(result) + # pylint: disable=too-many-locals def prepare_environment( # noqa: C901 self, required_collections: dict[str, str] | None = None, @@ -608,7 +610,10 @@ class Runtime: # https://docs.ansible.com/ansible-tower/latest/html/userguide/projects.html#ansible-galaxy-support # https://docs.ansible.com/ansible-tower/latest/html/userguide/projects.html#collections-support for req_file in REQUIREMENT_LOCATIONS: - self.install_requirements(Path(req_file), retry=retry, offline=offline) + file_path = Path(req_file) + if self.project_dir: + file_path = self.project_dir / req_file + self.install_requirements(file_path, retry=retry, offline=offline) self._prepare_ansible_paths() @@ -773,13 +778,15 @@ class Runtime: ] alterations_list.extend( - [ - (roles_path, f"{self.cache_dir}/roles", False), - (library_paths, f"{self.cache_dir}/modules", False), - (collections_path, f"{self.cache_dir}/collections", False), - ] - if self.isolated - else [], + ( + [ + (roles_path, f"{self.cache_dir}/roles", False), + (library_paths, f"{self.cache_dir}/modules", False), + (collections_path, f"{self.cache_dir}/collections", False), + ] + if self.isolated + else [] + ), ) for path_list, path_, must_be_present in alterations_list: @@ -853,7 +860,7 @@ class Runtime: fqrn = _get_role_fqrn(galaxy_info, project_dir) if role_name_check in [0, 1]: - if not re.match(r"[a-z0-9][a-z0-9_]+\.[a-z][a-z0-9_]+$", fqrn): + if not re.match(r"[a-z0-9][a-z0-9_-]+\.[a-z][a-z0-9_]+$", fqrn): msg = MSG_INVALID_FQRL.format(fqrn) if role_name_check == 1: _logger.warning(msg) diff --git a/src/ansible_compat/schema.py b/src/ansible_compat/schema.py index 2950e08..d9d1206 100644 --- a/src/ansible_compat/schema.py +++ b/src/ansible_compat/schema.py @@ -1,4 +1,5 @@ """Utils for JSON Schema validation.""" + from __future__ import annotations import json diff --git a/src/ansible_compat/types.py b/src/ansible_compat/types.py index 4514606..44d3328 100644 --- a/src/ansible_compat/types.py +++ b/src/ansible_compat/types.py @@ -1,4 +1,5 @@ """Custom types.""" + from __future__ import annotations from collections.abc import Mapping, Sequence |