Skip to content

Commit 60aa790

Browse files
committed
fix: Resolve pr comments
1 parent 937435f commit 60aa790

File tree

13 files changed

+130
-128
lines changed

13 files changed

+130
-128
lines changed

django-stubs/contrib/admin/models.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class LogEntryManager(models.Manager[LogEntry]):
3232
action_flag: int,
3333
change_message: str | list[Any] = "",
3434
*,
35+
# Commit 27b68bc, django https://github.com/django/django/pull/19233
3536
single_object: bool = False,
3637
) -> list[LogEntry] | LogEntry: ...
3738

django-stubs/contrib/auth/models.pyi

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ class Permission(models.Model):
3030
content_type = models.ForeignKey[ContentType | Combinable, ContentType](ContentType, on_delete=models.CASCADE)
3131
content_type_id: int
3232
codename = models.CharField(max_length=100)
33-
group_set: ManyToManyDescriptor[Group, Group_permissions]
34-
user_set: ManyToManyDescriptor[User, User_permissions]
33+
group_set: ManyToManyDescriptor[Group, _Group_permissions]
34+
user_set: ManyToManyDescriptor[User, _User_permissions]
3535
def natural_key(self) -> tuple[str, str, str]: ...
3636

3737
class GroupManager(models.Manager[Group]):
@@ -40,7 +40,7 @@ class GroupManager(models.Manager[Group]):
4040
# This is a model that only exists in Django's model registry and doesn't have any
4141
# class statement form. It's the through model between 'Group' and 'Permission'.
4242
@type_check_only
43-
class Group_permissions(models.Model):
43+
class _Group_permissions(models.Model):
4444
objects: ClassVar[models.Manager[Self]]
4545

4646
id: models.AutoField
@@ -53,7 +53,7 @@ class Group_permissions(models.Model):
5353
# This is a model that only exists in Django's model registry and doesn't have any
5454
# class statement form. It's the through model between 'User' and 'Group'.
5555
@type_check_only
56-
class User_groups(models.Model):
56+
class _User_groups(models.Model):
5757
objects: ClassVar[models.Manager[Self]]
5858

5959
id: models.AutoField
@@ -66,7 +66,7 @@ class User_groups(models.Model):
6666
# This is a model that only exists in Django's model registry and doesn't have any
6767
# class statement form. It's the through model between 'User' and 'Permission'.
6868
@type_check_only
69-
class User_permissions(models.Model):
69+
class _User_permissions(models.Model):
7070
objects: ClassVar[models.Manager[Self]]
7171

7272
id: models.AutoField
@@ -82,8 +82,8 @@ class Group(models.Model):
8282
id: models.AutoField
8383
pk: models.AutoField
8484
name = models.CharField(max_length=150)
85-
permissions = models.ManyToManyField[Permission, Group_permissions](Permission)
86-
user_set: ManyToManyDescriptor[User, User_groups]
85+
permissions = models.ManyToManyField[Permission, _Group_permissions](Permission)
86+
user_set: ManyToManyDescriptor[User, _User_groups]
8787
def natural_key(self) -> tuple[str]: ...
8888

8989
_T = TypeVar("_T", bound=Model)
@@ -106,8 +106,8 @@ class UserManager(BaseUserManager[_T]):
106106

107107
class PermissionsMixin(models.Model):
108108
is_superuser = models.BooleanField()
109-
groups = models.ManyToManyField[Group, User_groups](Group)
110-
user_permissions = models.ManyToManyField[Permission, User_permissions](Permission)
109+
groups = models.ManyToManyField[Group, _User_groups](Group)
110+
user_permissions = models.ManyToManyField[Permission, _User_permissions](Permission)
111111

112112
def get_user_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ...
113113
def get_group_permissions(self, obj: _AnyUser | None = ...) -> set[str]: ...

django-stubs/contrib/flatpages/models.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ from typing_extensions import Self
88
# This is a model that only exists in Django's model registry and doesn't have any
99
# class statement form. It's the through model between 'FlatPage' and 'Site'.
1010
@type_check_only
11-
class FlatPage_sites(models.Model):
11+
class _FlatPage_sites(models.Model):
1212
objects: ClassVar[models.Manager[Self]]
1313

1414
id: models.AutoField
@@ -27,5 +27,5 @@ class FlatPage(models.Model):
2727
enable_comments: models.BooleanField
2828
template_name: models.CharField
2929
registration_required: models.BooleanField
30-
sites: models.ManyToManyField[Site, FlatPage_sites]
30+
sites: models.ManyToManyField[Site, _FlatPage_sites]
3131
def get_absolute_url(self) -> str: ...

django-stubs/contrib/gis/db/models/fields.pyi

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -22,51 +22,9 @@ from django.utils.functional import _StrOrPromise
2222
_ST = TypeVar("_ST")
2323
# __get__ return type
2424
_GT = TypeVar("_GT")
25-
26-
_ST_PointField = TypeVar("_ST_PointField", default=Point | Combinable)
27-
_GT_PointField = TypeVar("_GT_PointField", default=Point)
28-
_Form_PointField = TypeVar("_Form_PointField", bound=forms.PointField, default=forms.PointField)
29-
_Geom_PointField = TypeVar("_Geom_PointField", bound=Point, default=Point)
30-
31-
_ST_LineStringField = TypeVar("_ST_LineStringField", default=LineString | Combinable)
32-
_GT_LineStringField = TypeVar("_GT_LineStringField", default=LineString)
33-
_Form_LineStringField = TypeVar("_Form_LineStringField", bound=forms.LineStringField, default=forms.LineStringField)
34-
_Geom_LineStringField = TypeVar("_Geom_LineStringField", bound=LineString, default=LineString)
35-
36-
_ST_PolygonField = TypeVar("_ST_PolygonField", default=Polygon | Combinable)
37-
_GT_PolygonField = TypeVar("_GT_PolygonField", default=Polygon)
38-
_Form_PolygonField = TypeVar("_Form_PolygonField", bound=forms.PolygonField, default=forms.PolygonField)
39-
_Geom_PolygonField = TypeVar("_Geom_PolygonField", bound=Polygon, default=Polygon)
40-
41-
_ST_MultiPointField = TypeVar("_ST_MultiPointField", default=MultiPoint | Combinable)
42-
_GT_MultiPointField = TypeVar("_GT_MultiPointField", default=MultiPoint)
43-
_Form_MultiPointField = TypeVar("_Form_MultiPointField", bound=forms.MultiPointField, default=forms.MultiPointField)
44-
_Geom_MultiPointField = TypeVar("_Geom_MultiPointField", bound=MultiPoint, default=MultiPoint)
45-
46-
_ST_MultiLineStringField = TypeVar("_ST_MultiLineStringField", default=MultiLineString | Combinable)
47-
_GT_MultiLineStringField = TypeVar("_GT_MultiLineStringField", default=MultiLineString)
48-
_Form_MultiLineStringField = TypeVar(
49-
"_Form_MultiLineStringField", bound=forms.MultiLineStringField, default=forms.MultiLineStringField
50-
)
51-
_Geom_MultiLineStringField = TypeVar("_Geom_MultiLineStringField", bound=MultiLineString, default=MultiLineString)
52-
53-
_ST_MultiPolygonField = TypeVar("_ST_MultiPolygonField", default=MultiPolygon | Combinable)
54-
_GT_MultiPolygonField = TypeVar("_GT_MultiPolygonField", default=MultiPolygon)
55-
_Form_MultiPolygonField = TypeVar(
56-
"_Form_MultiPolygonField", bound=forms.MultiPolygonField, default=forms.MultiPolygonField
57-
)
58-
_Geom_MultiPolygonField = TypeVar("_Geom_MultiPolygonField", bound=MultiPolygon, default=MultiPolygon)
59-
60-
_ST_GeometryCollectionField = TypeVar("_ST_GeometryCollectionField", default=GeometryCollection | Combinable)
61-
_GT_GeometryCollectionField = TypeVar("_GT_GeometryCollectionField", default=GeometryCollection)
62-
_Form_GeometryCollectionField = TypeVar(
63-
"_Form_GeometryCollectionField", bound=forms.GeometryCollectionField, default=forms.GeometryCollectionField
64-
)
65-
_Geom_GeometryCollectionField = TypeVar(
66-
"_Geom_GeometryCollectionField", bound=GeometryCollection, default=GeometryCollection
67-
)
68-
25+
# Form class type
6926
_Form_ClassT = TypeVar("_Form_ClassT", bound=forms.GeometryField)
27+
# Geometry class type
7028
_GEOM_ClassT = TypeVar("_GEOM_ClassT", bound=GEOSGeometry)
7129

7230
class SRIDCacheEntry(NamedTuple):
@@ -77,11 +35,11 @@ class SRIDCacheEntry(NamedTuple):
7735

7836
def get_srid_info(srid: int, connection: Any) -> SRIDCacheEntry: ...
7937
@type_check_only
80-
class SpatialClassField(Generic[_Form_ClassT, _GEOM_ClassT]):
38+
class _SpatialClassField(Generic[_Form_ClassT, _GEOM_ClassT]):
8139
form_class: type[_Form_ClassT]
8240
geom_class: type[_GEOM_ClassT] | None
8341

84-
class BaseSpatialField(Field[_ST, _GT], SpatialClassField[_Form_ClassT, _GEOM_ClassT]):
42+
class BaseSpatialField(Field[_ST, _GT], _SpatialClassField[_Form_ClassT, _GEOM_ClassT]):
8543
geom_type: str
8644
geography: bool
8745
spatial_index: bool
@@ -170,30 +128,57 @@ class GeometryField(BaseSpatialField[_ST, _GT, _Form_ClassT, _GEOM_ClassT]):
170128
**kwargs: Any,
171129
) -> forms.GeometryField: ...
172130

131+
_ST_PointField = TypeVar("_ST_PointField", default=Point | Combinable)
132+
_GT_PointField = TypeVar("_GT_PointField", default=Point)
133+
_Form_PointField = TypeVar("_Form_PointField", bound=forms.PointField, default=forms.PointField)
134+
_Geom_PointField = TypeVar("_Geom_PointField", bound=Point, default=Point)
135+
173136
class PointField(GeometryField[_ST_PointField, _GT_PointField, _Form_PointField, _Geom_PointField]):
174137
_pyi_private_set_type: Point | Combinable
175138
_pyi_private_get_type: Point
176139
_pyi_lookup_exact_type: Point
177140

141+
_ST_LineStringField = TypeVar("_ST_LineStringField", default=LineString | Combinable)
142+
_GT_LineStringField = TypeVar("_GT_LineStringField", default=LineString)
143+
_Form_LineStringField = TypeVar("_Form_LineStringField", bound=forms.LineStringField, default=forms.LineStringField)
144+
_Geom_LineStringField = TypeVar("_Geom_LineStringField", bound=LineString, default=LineString)
145+
178146
class LineStringField(
179147
GeometryField[_ST_LineStringField, _GT_LineStringField, _Form_LineStringField, _Geom_LineStringField]
180148
):
181149
_pyi_private_set_type: LineString | Combinable
182150
_pyi_private_get_type: LineString
183151
_pyi_lookup_exact_type: LineString
184152

153+
_ST_PolygonField = TypeVar("_ST_PolygonField", default=Polygon | Combinable)
154+
_GT_PolygonField = TypeVar("_GT_PolygonField", default=Polygon)
155+
_Form_PolygonField = TypeVar("_Form_PolygonField", bound=forms.PolygonField, default=forms.PolygonField)
156+
_Geom_PolygonField = TypeVar("_Geom_PolygonField", bound=Polygon, default=Polygon)
157+
185158
class PolygonField(GeometryField[_ST_PolygonField, _GT_PolygonField, _Form_PolygonField, _Geom_PolygonField]):
186159
_pyi_private_set_type: Polygon | Combinable
187160
_pyi_private_get_type: Polygon
188161
_pyi_lookup_exact_type: Polygon
189162

163+
_ST_MultiPointField = TypeVar("_ST_MultiPointField", default=MultiPoint | Combinable)
164+
_GT_MultiPointField = TypeVar("_GT_MultiPointField", default=MultiPoint)
165+
_Form_MultiPointField = TypeVar("_Form_MultiPointField", bound=forms.MultiPointField, default=forms.MultiPointField)
166+
_Geom_MultiPointField = TypeVar("_Geom_MultiPointField", bound=MultiPoint, default=MultiPoint)
167+
190168
class MultiPointField(
191169
GeometryField[_ST_MultiPointField, _GT_MultiPointField, _Form_MultiPointField, _Geom_MultiPointField]
192170
):
193171
_pyi_private_set_type: MultiPoint | Combinable
194172
_pyi_private_get_type: MultiPoint
195173
_pyi_lookup_exact_type: MultiPoint
196174

175+
_ST_MultiLineStringField = TypeVar("_ST_MultiLineStringField", default=MultiLineString | Combinable)
176+
_GT_MultiLineStringField = TypeVar("_GT_MultiLineStringField", default=MultiLineString)
177+
_Form_MultiLineStringField = TypeVar(
178+
"_Form_MultiLineStringField", bound=forms.MultiLineStringField, default=forms.MultiLineStringField
179+
)
180+
_Geom_MultiLineStringField = TypeVar("_Geom_MultiLineStringField", bound=MultiLineString, default=MultiLineString)
181+
197182
class MultiLineStringField(
198183
GeometryField[
199184
_ST_MultiLineStringField, _GT_MultiLineStringField, _Form_MultiLineStringField, _Geom_MultiLineStringField
@@ -203,13 +188,29 @@ class MultiLineStringField(
203188
_pyi_private_get_type: MultiLineString
204189
_pyi_lookup_exact_type: MultiLineString
205190

191+
_ST_MultiPolygonField = TypeVar("_ST_MultiPolygonField", default=MultiPolygon | Combinable)
192+
_GT_MultiPolygonField = TypeVar("_GT_MultiPolygonField", default=MultiPolygon)
193+
_Form_MultiPolygonField = TypeVar(
194+
"_Form_MultiPolygonField", bound=forms.MultiPolygonField, default=forms.MultiPolygonField
195+
)
196+
_Geom_MultiPolygonField = TypeVar("_Geom_MultiPolygonField", bound=MultiPolygon, default=MultiPolygon)
197+
206198
class MultiPolygonField(
207199
GeometryField[_ST_MultiPolygonField, _GT_MultiPolygonField, _Form_MultiPolygonField, _Geom_MultiPolygonField]
208200
):
209201
_pyi_private_set_type: MultiPolygon | Combinable
210202
_pyi_private_get_type: MultiPolygon
211203
_pyi_lookup_exact_type: MultiPolygon
212204

205+
_ST_GeometryCollectionField = TypeVar("_ST_GeometryCollectionField", default=GeometryCollection | Combinable)
206+
_GT_GeometryCollectionField = TypeVar("_GT_GeometryCollectionField", default=GeometryCollection)
207+
_Form_GeometryCollectionField = TypeVar(
208+
"_Form_GeometryCollectionField", bound=forms.GeometryCollectionField, default=forms.GeometryCollectionField
209+
)
210+
_Geom_GeometryCollectionField = TypeVar(
211+
"_Geom_GeometryCollectionField", bound=GeometryCollection, default=GeometryCollection
212+
)
213+
213214
class GeometryCollectionField(
214215
GeometryField[
215216
_ST_GeometryCollectionField,

django-stubs/contrib/sites/models.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Any, ClassVar
22

3-
from django.contrib.flatpages.models import FlatPage, FlatPage_sites
3+
from django.contrib.flatpages.models import FlatPage, _FlatPage_sites
44
from django.contrib.redirects.models import Redirect
55
from django.db import models
66
from django.db.models.fields.related_descriptors import ManyToManyDescriptor, ReverseManyToOneDescriptor
@@ -20,7 +20,7 @@ class Site(models.Model):
2020
pk: models.AutoField
2121
domain = models.CharField(max_length=100)
2222
name = models.CharField(max_length=50)
23-
flatpage_set: ManyToManyDescriptor[FlatPage, FlatPage_sites]
23+
flatpage_set: ManyToManyDescriptor[FlatPage, _FlatPage_sites]
2424
redirect_set: ReverseManyToOneDescriptor[Redirect]
2525
def natural_key(self) -> tuple[str]: ...
2626

0 commit comments

Comments
 (0)