From 3ce0131db6de7a82a60b09c47eab95f8f36ccc61 Mon Sep 17 00:00:00 2001 From: Maarten ter Huurne Date: Fri, 17 Mar 2023 13:04:48 +0100 Subject: [PATCH] Pass `Field` instead of `str` to `DeferredAttributeTracker` constructor This makes it pass mypy inspection, but there is no test coverage, so I'm not certain this solution is correct. However, as the code was already broken, it's unlikely to make things worse. https://github.com/jazzband/django-model-utils/issues/559 --- model_utils/tracker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/model_utils/tracker.py b/model_utils/tracker.py index eab1d4af..1fa4a96f 100644 --- a/model_utils/tracker.py +++ b/model_utils/tracker.py @@ -332,12 +332,12 @@ def _get_field_name(self) -> str: self.instance._deferred_fields = self.instance.get_deferred_fields() for field in self.instance._deferred_fields: - field_obj = self.instance.__class__.__dict__.get(field) + field_obj: models.Field = self.instance.__class__.__dict__[field] if isinstance(field_obj, FileDescriptor): file_descriptor_tracker = FileDescriptorTracker(field_obj.field) setattr(self.instance.__class__, field, file_descriptor_tracker) else: - deferred_attribute_tracker = DeferredAttributeTracker(field) + deferred_attribute_tracker = DeferredAttributeTracker(field_obj) setattr(self.instance.__class__, field, deferred_attribute_tracker)