From c3db67bf1d50dbdbd91cae77a9d2c8b80602f698 Mon Sep 17 00:00:00 2001 From: zandercymatics <141044360+zandercymatics@users.noreply.github.com> Date: Mon, 6 May 2024 08:24:00 -0600 Subject: [PATCH] Add check for linter --- src/registrar/models/domain.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/registrar/models/domain.py b/src/registrar/models/domain.py index 92c38b8d7..359df1c27 100644 --- a/src/registrar/models/domain.py +++ b/src/registrar/models/domain.py @@ -1969,8 +1969,13 @@ class Domain(TimeStampedModel, DomainHelper): # Q: Should we be deleting the newest or the oldest? Does it even matter? oldest_duplicate = db_contact.order_by("created_at").first() - # Exclude the oldest - duplicates_to_delete = db_contact.exclude(id=oldest_duplicate.id) # noqa + # The linter wants this check on the id, though in practice + # this should be otherwise impossible. + if hasattr(oldest_duplicate, "id"): + # Exclude the oldest + duplicates_to_delete = db_contact.exclude(id=oldest_duplicate.id) + else: + duplicates_to_delete = db_contact # Delete all duplicates duplicates_to_delete.delete()