|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | | -from typing import ClassVar |
| 3 | +from typing import ClassVar, TypeVar |
4 | 4 |
|
5 | 5 | from django.db import models |
6 | 6 | from django.db.models import Manager |
|
21 | 21 | from tests.fields import MutableField |
22 | 22 | from tests.managers import CustomSoftDeleteManager |
23 | 23 |
|
| 24 | +ModelT = TypeVar('ModelT', bound=models.Model, covariant=True) |
| 25 | + |
24 | 26 |
|
25 | 27 | class InheritanceManagerTestRelated(models.Model): |
26 | 28 | pass |
@@ -122,7 +124,7 @@ class DoubleMonitored(models.Model): |
122 | 124 |
|
123 | 125 |
|
124 | 126 | class Status(StatusModel): |
125 | | - STATUS = Choices( |
| 127 | + STATUS: Choices[str] = Choices( |
126 | 128 | ("active", _("active")), |
127 | 129 | ("deleted", _("deleted")), |
128 | 130 | ("on_hold", _("on hold")), |
@@ -178,7 +180,8 @@ class Post(models.Model): |
178 | 180 | public: ClassVar[QueryManager[Post]] = QueryManager(published=True) |
179 | 181 | public_confirmed: ClassVar[QueryManager[Post]] = QueryManager( |
180 | 182 | models.Q(published=True) & models.Q(confirmed=True)) |
181 | | - public_reversed = QueryManager(published=True).order_by("-order") |
| 183 | + public_reversed: QueryManager[Post] = QueryManager( |
| 184 | + published=True).order_by("-order") |
182 | 185 |
|
183 | 186 | class Meta: |
184 | 187 | ordering = ("order",) |
@@ -240,7 +243,7 @@ class TrackedFK(models.Model): |
240 | 243 |
|
241 | 244 | class TrackedAbstract(AbstractTracked): |
242 | 245 | name = models.CharField(max_length=20) |
243 | | - number = models.IntegerField() |
| 246 | + number = models.IntegerField() # type: ignore[assignment] |
244 | 247 | mutable = MutableField(default=None) |
245 | 248 |
|
246 | 249 | tracker = FieldTracker() |
|
0 commit comments