diff options
Diffstat (limited to 'lib/ansible/galaxy/dependency_resolution/dataclasses.py')
-rw-r--r-- | lib/ansible/galaxy/dependency_resolution/dataclasses.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/ansible/galaxy/dependency_resolution/dataclasses.py b/lib/ansible/galaxy/dependency_resolution/dataclasses.py index 0a942d4cce..681351d8fb 100644 --- a/lib/ansible/galaxy/dependency_resolution/dataclasses.py +++ b/lib/ansible/galaxy/dependency_resolution/dataclasses.py @@ -166,6 +166,7 @@ def _is_concrete_artifact_pointer(tested_str): class _ComputedReqKindsMixin: + UNIQUE_ATTRS = ('fqcn', 'ver', 'src', 'type') def __init__(self, *args, **kwargs): if not self.may_have_offline_galaxy_info: @@ -180,6 +181,12 @@ class _ComputedReqKindsMixin: self.ver ) + def __hash__(self): + return hash(tuple(getattr(self, attr) for attr in _ComputedReqKindsMixin.UNIQUE_ATTRS)) + + def __eq__(self, candidate): + return hash(self) == hash(candidate) + @classmethod def from_dir_path_as_unknown( # type: ignore[misc] cls, # type: t.Type[Collection] |