Skip to content

Commit

Permalink
fix model.object type hint
Browse files Browse the repository at this point in the history
  • Loading branch information
djbrown committed Dec 8, 2022
1 parent 7f39904 commit 5542ab7
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/base/tests/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
from contextlib import contextmanager
from typing import Type

import pytest
from django.conf import settings
Expand Down Expand Up @@ -95,12 +96,11 @@ def decorator(obj):

class ModelTestCase(TestCase):

def assert_objects(self, model: Model, count=1, filters=None) -> Model | QuerySet[Model]:
def assert_objects(self, model: Type[Model], count=1, filters=None) -> Model | QuerySet[Model]:
if filters is None:
filters = {}

objects = model.objects.filter(**filters) # type: ignore[attr-defined]
# see https://github.com/typeddjango/django-stubs/issues/1285
objects = model.objects.filter(**filters)
self.assertEqual(len(objects), count)
return objects[0] if count == 1 else objects

Expand Down

0 comments on commit 5542ab7

Please sign in to comment.