Skip to content

Commit

Permalink
Suppress pending issues in django-stubs
Browse files Browse the repository at this point in the history
I have submitted PRs to address these, but they haven't made it into
a release yet.
  • Loading branch information
mthuurne committed Apr 10, 2024
1 parent 0b1e94c commit a80bea3
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions model_utils/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion model_utils/tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fields/test_field_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit a80bea3

Please sign in to comment.