Skip to content

Commit

Permalink
Pass Field instead of str to DeferredAttributeTracker constructor
Browse files Browse the repository at this point in the history
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.

#559
  • Loading branch information
mthuurne committed Mar 17, 2023
1 parent d2ed6ee commit 30de857
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions model_utils/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 30de857

Please sign in to comment.