Avoid duplicate detectable tag (#45160)

in case of inheritance the static tags prop may be updated multiple
times, and it turns out builder classes magically inherit from
traditional package classes
This commit is contained in:
Harmen Stoppels 2024-07-10 18:14:28 +02:00 committed by Harmen Stoppels
parent d8a6aa551e
commit 7b644719c1

View file

@ -199,10 +199,10 @@ def __init__(cls, name, bases, attr_dict):
# assumed to be detectable # assumed to be detectable
if hasattr(cls, "executables") or hasattr(cls, "libraries"): if hasattr(cls, "executables") or hasattr(cls, "libraries"):
# Append a tag to each detectable package, so that finding them is faster # Append a tag to each detectable package, so that finding them is faster
if hasattr(cls, "tags"): if not hasattr(cls, "tags"):
getattr(cls, "tags").append(DetectablePackageMeta.TAG)
else:
setattr(cls, "tags", [DetectablePackageMeta.TAG]) setattr(cls, "tags", [DetectablePackageMeta.TAG])
elif DetectablePackageMeta.TAG not in cls.tags:
cls.tags.append(DetectablePackageMeta.TAG)
@classmethod @classmethod
def platform_executables(cls): def platform_executables(cls):