Skip to content

Commit 6504122

Browse files
committed
Missing better handling of the current User model
1 parent 66f9bcf commit 6504122

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

pytest_django/asserts.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def assertion_func(*args: Any, **kwargs: Any) -> Any:
5656

5757
if TYPE_CHECKING:
5858
from collections.abc import Collection, Iterator, Sequence
59-
from typing import overload
59+
from typing import ContextManager, overload
6060

6161
from django import forms
6262
from django.db.models import Model, QuerySet, RawQuerySet
@@ -213,7 +213,10 @@ def assertQuerySetEqual(
213213
) -> None: ...
214214

215215
@overload
216-
def assertNumQueries(num: int, func: None = None, *, using: str = ...) -> None: ...
216+
def assertNumQueries(
217+
num: int, func: None = None, *, using: str = ...
218+
) -> ContextManager[None]: ...
219+
217220
@overload
218221
def assertNumQueries(
219222
num: int, func: Callable[..., Any], *args: Any, using: str = ..., **kwargs: Any

pytest_django/fixtures.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ def django_user_model(db: None) -> type[django.contrib.auth.models.User]:
462462
"""The class of Django's user model."""
463463
from django.contrib.auth import get_user_model
464464

465-
return get_user_model()
465+
return get_user_model() # type: ignore[no-any-return]
466466

467467

468468
@pytest.fixture

pytest_django/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454

5555

5656
if TYPE_CHECKING:
57-
from typing import Any, NoReturn, Self
57+
from typing import Any, NoReturn
5858

5959
import django
6060

@@ -573,7 +573,7 @@ def _django_setup_unittest(
573573

574574
original_runtest = TestCaseFunction.runtest
575575

576-
def non_debugging_runtest(self: Self) -> None:
576+
def non_debugging_runtest(self) -> None:
577577
self._testcase(result=self)
578578

579579
from django.test import SimpleTestCase

0 commit comments

Comments
 (0)