Skip to content

Commit e31a5c6

Browse files
committed
Explicitly annotate some fields in the auth module
This is required to run mypy without the plugin, as it would complain about these fields requiring an annotation. Using `follow_imports = silent` did not work in this case Also feels more natural than doing an assignment in a stub file
1 parent a2c10f5 commit e31a5c6

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

django-stubs/contrib/auth/models.pyi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ from django.contrib.contenttypes.models import ContentType
88
from django.db import models
99
from django.db.models import QuerySet
1010
from django.db.models.base import Model
11+
from django.db.models.expressions import Combinable
1112
from django.db.models.manager import EmptyManager
1213
from django.utils.functional import _StrOrPromise
1314
from typing_extensions import Self, TypeAlias
@@ -23,9 +24,9 @@ class Permission(models.Model):
2324
content_type_id: int
2425
objects: ClassVar[PermissionManager]
2526

26-
name = models.CharField(max_length=255)
27-
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE)
28-
codename = models.CharField(max_length=100)
27+
name: models.CharField[str | int | Combinable, str]
28+
content_type: models.ForeignKey[ContentType | Combinable, ContentType]
29+
codename: models.CharField[str | int | Combinable, str]
2930
def natural_key(self) -> tuple[str, str, str]: ...
3031

3132
class GroupManager(models.Manager[Group]):
@@ -34,7 +35,7 @@ class GroupManager(models.Manager[Group]):
3435
class Group(models.Model):
3536
objects: ClassVar[GroupManager]
3637

37-
name = models.CharField(max_length=150)
38+
name: models.CharField[str | int | Combinable, str]
3839
permissions = models.ManyToManyField(Permission)
3940
def natural_key(self) -> tuple[str]: ...
4041

0 commit comments

Comments
 (0)