summaryrefslogtreecommitdiff
path: root/lib/ansible/galaxy
diff options
context:
space:
mode:
authorLee Garrett <lgarrett@rocketjump.eu>2022-09-13 16:39:18 +0200
committerLee Garrett <lgarrett@rocketjump.eu>2022-09-13 16:39:18 +0200
commitdfc95dfc10415e8ba138e2c042c39632c9251abb (patch)
treef0d4aac54ea7f6ef3ffb1b61d4a316fab0d2602c /lib/ansible/galaxy
parent5883937d823fe68e35dbedf2a9d45ecaf6636470 (diff)
downloaddebian-ansible-core-dfc95dfc10415e8ba138e2c042c39632c9251abb.zip
New upstream version 2.13.4
Diffstat (limited to 'lib/ansible/galaxy')
-rw-r--r--lib/ansible/galaxy/collection/__init__.py2
-rw-r--r--lib/ansible/galaxy/collection/concrete_artifact_manager.py36
-rw-r--r--lib/ansible/galaxy/collection/gpg.py2
-rw-r--r--lib/ansible/galaxy/dependency_resolution/providers.py4
4 files changed, 22 insertions, 22 deletions
diff --git a/lib/ansible/galaxy/collection/__init__.py b/lib/ansible/galaxy/collection/__init__.py
index 220285ad..9812bcad 100644
--- a/lib/ansible/galaxy/collection/__init__.py
+++ b/lib/ansible/galaxy/collection/__init__.py
@@ -180,7 +180,7 @@ class CollectionVerifyResult:
def verify_local_collection(
local_collection, remote_collection,
artifacts_manager,
-): # type: (Candidate, Candidate | None, ConcreteArtifactsManager) -> CollectionVerifyResult
+): # type: (Candidate, t.Optional[Candidate], ConcreteArtifactsManager) -> CollectionVerifyResult
"""Verify integrity of the locally installed collection.
:param local_collection: Collection being checked.
diff --git a/lib/ansible/galaxy/collection/concrete_artifact_manager.py b/lib/ansible/galaxy/collection/concrete_artifact_manager.py
index 1ef7eed2..4115aeed 100644
--- a/lib/ansible/galaxy/collection/concrete_artifact_manager.py
+++ b/lib/ansible/galaxy/collection/concrete_artifact_manager.py
@@ -100,7 +100,7 @@ class ConcreteArtifactsManager:
self._require_build_metadata = value
def get_galaxy_artifact_source_info(self, collection):
- # type: (Candidate) -> dict[str, str | list[dict[str, str]]]
+ # type: (Candidate) -> dict[str, t.Union[str, list[dict[str, str]]]]
server = collection.src.api_server
try:
@@ -124,7 +124,7 @@ class ConcreteArtifactsManager:
}
def get_galaxy_artifact_path(self, collection):
- # type: (Candidate | Requirement) -> bytes
+ # type: (t.Union[Candidate, Requirement]) -> bytes
"""Given a Galaxy-stored collection, return a cached path.
If it's not yet on disk, this method downloads the artifact first.
@@ -184,7 +184,7 @@ class ConcreteArtifactsManager:
return b_artifact_path
def get_artifact_path(self, collection):
- # type: (Candidate | Requirement) -> bytes
+ # type: (t.Union[Candidate, Requirement]) -> bytes
"""Given a concrete collection pointer, return a cached path.
If it's not yet on disk, this method downloads the artifact first.
@@ -249,15 +249,15 @@ class ConcreteArtifactsManager:
return b_artifact_path
def _get_direct_collection_namespace(self, collection):
- # type: (Candidate) -> str | None
+ # type: (Candidate) -> t.Optional[str]
return self.get_direct_collection_meta(collection)['namespace'] # type: ignore[return-value]
def _get_direct_collection_name(self, collection):
- # type: (Candidate) -> str | None
+ # type: (Candidate) -> t.Optional[str]
return self.get_direct_collection_meta(collection)['name'] # type: ignore[return-value]
def get_direct_collection_fqcn(self, collection):
- # type: (Candidate) -> str | None
+ # type: (Candidate) -> t.Optional[str]
"""Extract FQCN from the given on-disk collection artifact.
If the collection is virtual, ``None`` is returned instead
@@ -273,17 +273,17 @@ class ConcreteArtifactsManager:
))
def get_direct_collection_version(self, collection):
- # type: (Candidate | Requirement) -> str
+ # type: (t.Union[Candidate, Requirement]) -> str
"""Extract version from the given on-disk collection artifact."""
return self.get_direct_collection_meta(collection)['version'] # type: ignore[return-value]
def get_direct_collection_dependencies(self, collection):
- # type: (Candidate | Requirement) -> dict[str, str]
+ # type: (t.Union[Candidate, Requirement]) -> dict[str, str]
"""Extract deps from the given on-disk collection artifact."""
return self.get_direct_collection_meta(collection)['dependencies'] # type: ignore[return-value]
def get_direct_collection_meta(self, collection):
- # type: (Candidate | Requirement) -> dict[str, str | dict[str, str] | list[str] | None]
+ # type: (t.Union[Candidate, Requirement]) -> dict[str, t.Union[str, dict[str, str], list[str], None]]
"""Extract meta from the given on-disk collection artifact."""
try: # FIXME: use unique collection identifier as a cache key?
return self._artifact_meta_cache[collection.src]
@@ -457,7 +457,7 @@ def _extract_collection_from_git(repo_url, coll_ver, b_path):
# FIXME: use random subdirs while preserving the file names
def _download_file(url, b_path, expected_hash, validate_certs, token=None, timeout=60):
- # type: (str, bytes, str | None, bool, GalaxyToken, int) -> bytes
+ # type: (str, bytes, t.Optional[str], bool, GalaxyToken, int) -> bytes
# ^ NOTE: used in download and verify_collections ^
b_tarball_name = to_bytes(
url.rsplit('/', 1)[1], errors='surrogate_or_strict',
@@ -513,15 +513,15 @@ def _consume_file(read_from, write_to=None):
def _normalize_galaxy_yml_manifest(
- galaxy_yml, # type: dict[str, str | list[str] | dict[str, str] | None]
+ galaxy_yml, # type: dict[str, t.Union[str, list[str], dict[str, str], None]]
b_galaxy_yml_path, # type: bytes
require_build_metadata=True, # type: bool
):
- # type: (...) -> dict[str, str | list[str] | dict[str, str] | None]
+ # type: (...) -> dict[str, t.Union[str, list[str], dict[str, str], None]]
galaxy_yml_schema = (
get_collections_galaxy_meta_info()
) # type: list[dict[str, t.Any]] # FIXME: <--
- # FIXME: 👆maybe precise type: list[dict[str, bool | str | list[str]]]
+ # FIXME: 👆maybe precise type: list[dict[str, t.Union[bool, str, list[str]]]]
mandatory_keys = set()
string_keys = set() # type: set[str]
@@ -588,7 +588,7 @@ def _normalize_galaxy_yml_manifest(
def _get_meta_from_dir(
b_path, # type: bytes
require_build_metadata=True, # type: bool
-): # type: (...) -> dict[str, str | list[str] | dict[str, str] | None]
+): # type: (...) -> dict[str, t.Union[str, list[str], dict[str, str], None]]
try:
return _get_meta_from_installed_dir(b_path)
except LookupError:
@@ -598,7 +598,7 @@ def _get_meta_from_dir(
def _get_meta_from_src_dir(
b_path, # type: bytes
require_build_metadata=True, # type: bool
-): # type: (...) -> dict[str, str | list[str] | dict[str, str] | None]
+): # type: (...) -> dict[str, t.Union[str, list[str], dict[str, str], None]]
galaxy_yml = os.path.join(b_path, _GALAXY_YAML)
if not os.path.isfile(galaxy_yml):
raise LookupError(
@@ -667,7 +667,7 @@ def _get_json_from_installed_dir(
def _get_meta_from_installed_dir(
b_path, # type: bytes
-): # type: (...) -> dict[str, str | list[str] | dict[str, str] | None]
+): # type: (...) -> dict[str, t.Union[str, list[str], dict[str, str], None]]
manifest = _get_json_from_installed_dir(b_path, MANIFEST_FILENAME)
collection_info = manifest['collection_info']
@@ -688,7 +688,7 @@ def _get_meta_from_installed_dir(
def _get_meta_from_tar(
b_path, # type: bytes
-): # type: (...) -> dict[str, str | list[str] | dict[str, str] | None]
+): # type: (...) -> dict[str, t.Union[str, list[str], dict[str, str], None]]
if not tarfile.is_tarfile(b_path):
raise AnsibleError(
"Collection artifact at '{path!s}' is not a valid tar file.".
@@ -736,7 +736,7 @@ def _tarfile_extract(
tar, # type: tarfile.TarFile
member, # type: tarfile.TarInfo
):
- # type: (...) -> t.Iterator[tuple[tarfile.TarInfo, t.IO[bytes] | None]]
+ # type: (...) -> t.Iterator[tuple[tarfile.TarInfo, t.Optional[t.IO[bytes]]]]
tar_obj = tar.extractfile(member)
try:
yield member, tar_obj
diff --git a/lib/ansible/galaxy/collection/gpg.py b/lib/ansible/galaxy/collection/gpg.py
index f684de16..8641f0d7 100644
--- a/lib/ansible/galaxy/collection/gpg.py
+++ b/lib/ansible/galaxy/collection/gpg.py
@@ -25,7 +25,7 @@ IS_PY310_PLUS = sys.version_info[:2] >= (3, 10)
frozen_dataclass = partial(dataclass, frozen=True, **({'slots': True} if IS_PY310_PLUS else {}))
-def get_signature_from_source(source, display=None): # type: (str, Display | None) -> str
+def get_signature_from_source(source, display=None): # type: (str, t.Optional[Display]) -> str
if display is not None:
display.vvvv(f"Using signature at {source}")
try:
diff --git a/lib/ansible/galaxy/dependency_resolution/providers.py b/lib/ansible/galaxy/dependency_resolution/providers.py
index 947fae61..ccb56a9d 100644
--- a/lib/ansible/galaxy/dependency_resolution/providers.py
+++ b/lib/ansible/galaxy/dependency_resolution/providers.py
@@ -169,7 +169,7 @@ class CollectionDependencyProviderBase(AbstractProvider):
return False
def identify(self, requirement_or_candidate):
- # type: (Candidate | Requirement) -> str
+ # type: (t.Union[Candidate, Requirement]) -> str
"""Given requirement or candidate, return an identifier for it.
This is used to identify a requirement or candidate, e.g.
@@ -181,7 +181,7 @@ class CollectionDependencyProviderBase(AbstractProvider):
return requirement_or_candidate.canonical_package_id
def get_preference(self, *args, **kwargs):
- # type: (t.Any, t.Any) -> float | int
+ # type: (t.Any, t.Any) -> t.Union[float, int]
"""Return sort key function return value for given requirement.
This result should be based on preference that is defined as