diff --git a/model_utils/managers.py b/model_utils/managers.py index e3375b87..ef81c964 100644 --- a/model_utils/managers.py +++ b/model_utils/managers.py @@ -146,8 +146,8 @@ def _get_subclasses_recurse(self, model: type[models.Model]) -> list[str]: for rel in rels: for subclass in self._get_subclasses_recurse(rel.field.model): - subclasses.append(rel.get_accessor_name() + LOOKUP_SEP + subclass) - subclasses.append(rel.get_accessor_name()) + subclasses.append(cast(str, rel.get_accessor_name()) + LOOKUP_SEP + subclass) + subclasses.append(cast(str, rel.get_accessor_name())) return subclasses def _get_ancestors_path(self, model: type[models.Model]) -> str: @@ -167,7 +167,7 @@ def _get_ancestors_path(self, model: type[models.Model]) -> str: while parent_link is not None: related = parent_link.remote_field - ancestry.insert(0, related.get_accessor_name()) + ancestry.insert(0, cast(str, related.get_accessor_name())) parent_model = related.model parent_link = parent_model._meta.get_ancestor_link(self.model) diff --git a/model_utils/tracker.py b/model_utils/tracker.py index 0616508f..68bd338b 100644 --- a/model_utils/tracker.py +++ b/model_utils/tracker.py @@ -34,7 +34,7 @@ def __getstate__(self) -> dict[str, Any]: """ We don't need to deepcopy the instance, so nullify if provided. """ - state = super().__getstate__() + state = super().__getstate__() # type: ignore[misc] if 'instance' in state: state['instance'] = None return state diff --git a/tests/models.py b/tests/models.py index 79638f78..d17643d2 100644 --- a/tests/models.py +++ b/tests/models.py @@ -379,7 +379,7 @@ def __get__(self, obj: models.Model | None, cls: type[models.Model] | None = Non assert cls is not None fields_map = {f.name: f for f in cls._meta.fields} field = fields_map[self.name] - DeferredAttribute(field=field).__get__(obj, cls) + DeferredAttribute(field=field).__get__(obj, cls) # type: ignore[attr-defined] return str(obj.__dict__[self.name]) def __set__(self, obj: object, value: str) -> None: diff --git a/tests/test_fields/test_field_tracker.py b/tests/test_fields/test_field_tracker.py index a8ec8212..4ee77608 100644 --- a/tests/test_fields/test_field_tracker.py +++ b/tests/test_fields/test_field_tracker.py @@ -225,7 +225,7 @@ def test_refresh_from_db(self) -> None: self.assertChanged(name='retro', number=4, mutable=[1, 2, 3]) self.instance.refresh_from_db(fields=('name',)) self.assertChanged(number=4, mutable=[1, 2, 3]) - self.instance.refresh_from_db(fields={'mutable'}) + self.instance.refresh_from_db(fields={'mutable'}) # type: ignore[arg-type] self.assertChanged(number=4) self.instance.refresh_from_db() self.assertChanged()