-
-
Notifications
You must be signed in to change notification settings - Fork 452
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add explicit overload to Field
subclasses
#1900
base: master
Are you sure you want to change the base?
Changes from all commits
a2c10f5
e31a5c6
9cafb9d
3dda6c8
3a78871
ec4f339
b1e8662
9512835
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ from django.contrib.contenttypes.models import ContentType | |
from django.db import models | ||
from django.db.models import QuerySet | ||
from django.db.models.base import Model | ||
from django.db.models.expressions import Combinable | ||
from django.db.models.manager import EmptyManager | ||
from django.utils.functional import _StrOrPromise | ||
from typing_extensions import Self, TypeAlias | ||
|
@@ -23,9 +24,9 @@ class Permission(models.Model): | |
content_type_id: int | ||
objects: ClassVar[PermissionManager] | ||
|
||
name = models.CharField(max_length=255) | ||
content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE) | ||
codename = models.CharField(max_length=100) | ||
name: models.CharField[str | int | Combinable, str] | ||
content_type: models.ForeignKey[ContentType | Combinable, ContentType] | ||
codename: models.CharField[str | int | Combinable, str] | ||
def natural_key(self) -> tuple[str, str, str]: ... | ||
|
||
class GroupManager(models.Manager[Group]): | ||
|
@@ -34,7 +35,7 @@ class GroupManager(models.Manager[Group]): | |
class Group(models.Model): | ||
objects: ClassVar[GroupManager] | ||
|
||
name = models.CharField(max_length=150) | ||
name: models.CharField[str | int | Combinable, str] | ||
permissions = models.ManyToManyField(Permission) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... however I can't explicitly annotate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can have a look here how it can be done: https://github.com/typeddjango/django-stubs/pull/2214/files#diff-0236ca9e909bc4743fa03e6653fc33adbaaef02a34d8698501a63a59ad624f1fR42-R51 |
||
def natural_key(self) -> tuple[str]: ... | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having explicit assignments feels a bit weird in a stub file and was causing issues when testing without the plugin (had error code
var-annotated
)