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.

jazzband#559
  • Loading branch information
mthuurne committed Mar 21, 2023
1 parent 998eb70 commit 3ce0131
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 3ce0131

Please sign in to comment.