From 15ef8d945f013916bf1590d5d51c1b7c56c72445 Mon Sep 17 00:00:00 2001 From: Karataev Pavel Date: Thu, 29 Aug 2024 23:33:14 +0300 Subject: [PATCH 1/5] Fixup db.models.fields.Field overloads for pyright 1.1.378 (#264) --- .../contrib/postgres/fields/array.pyi | 6 +- .../contrib/postgres/fields/citext.pyi | 18 ++- .../contrib/postgres/fields/hstore.pyi | 6 +- django-stubs/db/models/fields/__init__.pyi | 138 ++++++++++++------ django-stubs/db/models/fields/json.pyi | 6 +- django-stubs/db/models/fields/related.pyi | 18 ++- 6 files changed, 128 insertions(+), 64 deletions(-) diff --git a/django-stubs/contrib/postgres/fields/array.pyi b/django-stubs/contrib/postgres/fields/array.pyi index d2faca050..f23f74eba 100644 --- a/django-stubs/contrib/postgres/fields/array.pyi +++ b/django-stubs/contrib/postgres/fields/array.pyi @@ -22,12 +22,13 @@ class ArrayField(CheckFieldDefaultMixin, Generic[_V], Field[_V | Combinable, _V] base_field: Field[Any, _V], size: int | None = ..., verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: list[_V] | Callable[[], list[_V]] | None = ..., editable: bool = ..., @@ -51,12 +52,13 @@ class ArrayField(CheckFieldDefaultMixin, Generic[_V], Field[_V | Combinable, _V] base_field: Field[Any, _V], size: int | None = ..., verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: list[_V] | Callable[[], list[_V]] | None = ..., editable: bool = ..., diff --git a/django-stubs/contrib/postgres/fields/citext.pyi b/django-stubs/contrib/postgres/fields/citext.pyi index b85e00010..64498f979 100644 --- a/django-stubs/contrib/postgres/fields/citext.pyi +++ b/django-stubs/contrib/postgres/fields/citext.pyi @@ -20,12 +20,13 @@ class CICharField(CIText, CharField[_C]): def __init__( self: CICharField[str], verbose_name: str | bytes | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: Any = ..., editable: bool = ..., @@ -45,12 +46,13 @@ class CICharField(CIText, CharField[_C]): def __init__( self: CICharField[str | None], verbose_name: str | bytes | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: Any = ..., editable: bool = ..., @@ -74,12 +76,13 @@ class CIEmailField(CIText, EmailField[_C]): def __init__( self: CIEmailField[str], verbose_name: str | bytes | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: Any = ..., editable: bool = ..., @@ -99,12 +102,13 @@ class CIEmailField(CIText, EmailField[_C]): def __init__( self: CIEmailField[str | None], verbose_name: str | bytes | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: Any = ..., editable: bool = ..., @@ -128,12 +132,13 @@ class CITextField(CIText, TextField[_C]): def __init__( self: CITextField[str], verbose_name: str | bytes | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: Any = ..., editable: bool = ..., @@ -153,12 +158,13 @@ class CITextField(CIText, TextField[_C]): def __init__( self: CITextField[str | None], verbose_name: str | bytes | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: Any = ..., editable: bool = ..., diff --git a/django-stubs/contrib/postgres/fields/hstore.pyi b/django-stubs/contrib/postgres/fields/hstore.pyi index cc506ca9e..c5c2fd564 100644 --- a/django-stubs/contrib/postgres/fields/hstore.pyi +++ b/django-stubs/contrib/postgres/fields/hstore.pyi @@ -19,12 +19,13 @@ class HStoreField(Generic[_T], CheckFieldDefaultMixin, Field[Any, Any]): def __init__( self: HStoreField[dict[str, str | None]], verbose_name: str | bytes | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: Any = ..., editable: bool = ..., @@ -44,12 +45,13 @@ class HStoreField(Generic[_T], CheckFieldDefaultMixin, Field[Any, Any]): def __init__( self: HStoreField[dict[str, str | None] | None], verbose_name: str | bytes | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: Any = ..., editable: bool = ..., diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 4cb1af1d8..1b5adb84b 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -117,12 +117,13 @@ class IntegerField(Generic[_I], Field[_I | Combinable, _I]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _I | Callable[[], _I] | None = ..., editable: bool = ..., @@ -143,12 +144,13 @@ class IntegerField(Generic[_I], Field[_I | Combinable, _I]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _I | Callable[[], _I] = ..., editable: bool = ..., @@ -174,12 +176,13 @@ class PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _I | Callable[[], _I] | None = ..., editable: bool = ..., @@ -200,12 +203,13 @@ class PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _I | Callable[[], _I] = ..., editable: bool = ..., @@ -228,12 +232,13 @@ class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I]) def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _I | Callable[[], _I] | None = ..., editable: bool = ..., @@ -253,12 +258,13 @@ class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I]) def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _I | Callable[[], _I] = ..., editable: bool = ..., @@ -281,12 +287,13 @@ class SmallIntegerField(IntegerField[_I]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _I | Callable[[], _I] | None = ..., editable: bool = ..., @@ -307,12 +314,13 @@ class SmallIntegerField(IntegerField[_I]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _I | Callable[[], _I] = ..., editable: bool = ..., @@ -335,12 +343,13 @@ class BigIntegerField(IntegerField[_I]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _I | Callable[[], _I] | None = ..., editable: bool = ..., @@ -361,12 +370,13 @@ class BigIntegerField(IntegerField[_I]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _I | Callable[[], _I] = ..., editable: bool = ..., @@ -389,12 +399,13 @@ class PositiveBigIntegerField(IntegerField[_I]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _I | Callable[[], _I] | None = ..., editable: bool = ..., @@ -415,12 +426,13 @@ class PositiveBigIntegerField(IntegerField[_I]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _I | Callable[[], _I] = ..., editable: bool = ..., @@ -445,12 +457,13 @@ class FloatField(Generic[_F], Field[_F | Combinable, _F]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _F | Callable[[], _F] | None = ..., editable: bool = ..., @@ -471,12 +484,13 @@ class FloatField(Generic[_F], Field[_F | Combinable, _F]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _F | Callable[[], _F] = ..., editable: bool = ..., @@ -504,6 +518,7 @@ class DecimalField(Generic[_DEC], Field[_DEC | Combinable, _DEC]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., max_digits: int = ..., decimal_places: int = ..., @@ -511,7 +526,7 @@ class DecimalField(Generic[_DEC], Field[_DEC | Combinable, _DEC]): max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _DEC | Callable[[], _DEC] | None = ..., editable: bool = ..., @@ -534,6 +549,7 @@ class DecimalField(Generic[_DEC], Field[_DEC | Combinable, _DEC]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., max_digits: int = ..., decimal_places: int = ..., @@ -541,7 +557,7 @@ class DecimalField(Generic[_DEC], Field[_DEC | Combinable, _DEC]): max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _DEC | Callable[[], _DEC] = ..., editable: bool = ..., @@ -664,13 +680,14 @@ class CharField(Generic[_C], Field[_C | Combinable, _C]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int = ..., db_collation: str | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _C | Callable[[], _C] | None = ..., editable: bool = ..., @@ -692,13 +709,14 @@ class CharField(Generic[_C], Field[_C | Combinable, _C]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int = ..., db_collation: str | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _C | Callable[[], _C] = ..., editable: bool = ..., @@ -722,13 +740,14 @@ class SlugField(CharField[_C]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int = ..., db_collation: str | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _C | Callable[[], _C] | None = ..., editable: bool = ..., @@ -750,13 +769,14 @@ class SlugField(CharField[_C]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int = ..., db_collation: str | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _C | Callable[[], _C] = ..., editable: bool = ..., @@ -780,13 +800,14 @@ class EmailField(CharField[_C]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int = ..., db_collation: str | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _C | Callable[[], _C] | None = ..., editable: bool = ..., @@ -807,13 +828,14 @@ class EmailField(CharField[_C]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int = ..., db_collation: str | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _C | Callable[[], _C] = ..., editable: bool = ..., @@ -836,13 +858,14 @@ class URLField(CharField[_C]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int = ..., db_collation: str | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _C | Callable[[], _C] | None = ..., editable: bool = ..., @@ -863,13 +886,14 @@ class URLField(CharField[_C]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int = ..., db_collation: str | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _C | Callable[[], _C] = ..., editable: bool = ..., @@ -892,13 +916,14 @@ class TextField(Generic[_C], Field[_C | Combinable, _C]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., db_collation: str | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _C | Callable[[], _C] | None = ..., editable: bool = ..., @@ -919,13 +944,14 @@ class TextField(Generic[_C], Field[_C | Combinable, _C]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., db_collation: str | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _C | Callable[[], _C] = ..., editable: bool = ..., @@ -950,13 +976,14 @@ class BooleanField(Generic[_B], Field[_B | Combinable, _B]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., db_collation: str | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _B | Callable[[], _B] | None = ..., editable: bool = ..., @@ -977,13 +1004,14 @@ class BooleanField(Generic[_B], Field[_B | Combinable, _B]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., db_collation: str | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _B | Callable[[], _B] = ..., editable: bool = ..., @@ -1005,12 +1033,13 @@ class IPAddressField(Generic[_C], Field[_C | Combinable, _C]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _C | Callable[[], _C] | None = ..., editable: bool = ..., @@ -1031,12 +1060,13 @@ class IPAddressField(Generic[_C], Field[_C | Combinable, _C]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _C | Callable[[], _C] = ..., editable: bool = ..., @@ -1062,6 +1092,7 @@ class GenericIPAddressField( def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., protocol: str = ..., unpack_ipv4: bool = ..., @@ -1069,7 +1100,7 @@ class GenericIPAddressField( max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _C | Callable[[], _C] | None = ..., editable: bool = ..., @@ -1090,6 +1121,7 @@ class GenericIPAddressField( def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., protocol: str = ..., unpack_ipv4: bool = ..., @@ -1097,7 +1129,7 @@ class GenericIPAddressField( max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _C | Callable[[], _C] = ..., editable: bool = ..., @@ -1127,6 +1159,7 @@ class DateField(DateTimeCheckMixin, Field[_DD | Combinable, _DD]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., auto_now: bool = ..., auto_now_add: bool = ..., @@ -1134,7 +1167,7 @@ class DateField(DateTimeCheckMixin, Field[_DD | Combinable, _DD]): max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _DD | Callable[[], _DD] | None = ..., editable: bool = ..., @@ -1157,6 +1190,7 @@ class DateField(DateTimeCheckMixin, Field[_DD | Combinable, _DD]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., auto_now: bool = ..., auto_now_add: bool = ..., @@ -1164,7 +1198,7 @@ class DateField(DateTimeCheckMixin, Field[_DD | Combinable, _DD]): max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _DD | Callable[[], _DD] = ..., editable: bool = ..., @@ -1194,6 +1228,7 @@ class TimeField(Generic[_TM], DateTimeCheckMixin, Field[_TM | Combinable, _TM]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., auto_now: bool = ..., auto_now_add: bool = ..., @@ -1201,7 +1236,7 @@ class TimeField(Generic[_TM], DateTimeCheckMixin, Field[_TM | Combinable, _TM]): max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _TM | Callable[[], _TM] | None = ..., editable: bool = ..., @@ -1224,6 +1259,7 @@ class TimeField(Generic[_TM], DateTimeCheckMixin, Field[_TM | Combinable, _TM]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., auto_now: bool = ..., auto_now_add: bool = ..., @@ -1231,7 +1267,7 @@ class TimeField(Generic[_TM], DateTimeCheckMixin, Field[_TM | Combinable, _TM]): max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _TM | Callable[[], _TM] = ..., editable: bool = ..., @@ -1261,6 +1297,7 @@ class DateTimeField(DateField[_DT]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., auto_now: bool = ..., auto_now_add: bool = ..., @@ -1268,7 +1305,7 @@ class DateTimeField(DateField[_DT]): max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _DT | Callable[[], _DT] | None = ..., editable: bool = ..., @@ -1291,6 +1328,7 @@ class DateTimeField(DateField[_DT]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., auto_now: bool = ..., auto_now_add: bool = ..., @@ -1298,7 +1336,7 @@ class DateTimeField(DateField[_DT]): max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _DT | Callable[[], _DT] = ..., editable: bool = ..., @@ -1325,12 +1363,13 @@ class UUIDField(Generic[_U], Field[str | _U, _U]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _U | Callable[[], _U] | None = ..., editable: bool = ..., @@ -1351,12 +1390,13 @@ class UUIDField(Generic[_U], Field[str | _U, _U]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _U | Callable[[], _U] = ..., editable: bool = ..., @@ -1384,6 +1424,7 @@ class FilePathField(Generic[_C], Field[_C, _C]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., path: str | Callable[..., str] = ..., match: str | None = ..., @@ -1394,7 +1435,7 @@ class FilePathField(Generic[_C], Field[_C, _C]): max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _C | Callable[[], _C] | None = ..., editable: bool = ..., @@ -1415,6 +1456,7 @@ class FilePathField(Generic[_C], Field[_C, _C]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., path: str | Callable[..., str] = ..., match: str | None = ..., @@ -1425,7 +1467,7 @@ class FilePathField(Generic[_C], Field[_C, _C]): max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _C | Callable[[], _C] = ..., editable: bool = ..., @@ -1450,12 +1492,13 @@ class BinaryField(Generic[_BIN], Field[_BIN | bytearray | memoryview, _BIN]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _BIN | Callable[[], _BIN] | None = ..., editable: bool = ..., @@ -1478,12 +1521,13 @@ class BinaryField(Generic[_BIN], Field[_BIN | bytearray | memoryview, _BIN]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _BIN | Callable[[], _BIN] = ..., editable: bool = ..., @@ -1510,12 +1554,13 @@ class DurationField(Generic[_TD], Field[_TD, _TD]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _TD | Callable[[], _TD] | None = ..., editable: bool = ..., @@ -1538,12 +1583,13 @@ class DurationField(Generic[_TD], Field[_TD, _TD]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., primary_key: bool = ..., max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _TD | Callable[[], _TD] = ..., editable: bool = ..., diff --git a/django-stubs/db/models/fields/json.pyi b/django-stubs/db/models/fields/json.pyi index b2a078962..2ef86ad09 100644 --- a/django-stubs/db/models/fields/json.pyi +++ b/django-stubs/db/models/fields/json.pyi @@ -23,6 +23,7 @@ class JSONField(CheckFieldDefaultMixin, Field[_A | Combinable, _A]): def __new__( # type: ignore [misc] cls, verbose_name: str | None = ..., + *, name: str | None = ..., encoder: type[json.JSONEncoder] = ..., decoder: type[json.JSONDecoder] = ..., @@ -30,7 +31,7 @@ class JSONField(CheckFieldDefaultMixin, Field[_A | Combinable, _A]): max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: Any | Callable[[], Any] | None = ..., editable: bool = ..., @@ -52,6 +53,7 @@ class JSONField(CheckFieldDefaultMixin, Field[_A | Combinable, _A]): def __new__( cls, verbose_name: str | None = ..., + *, name: str | None = ..., encoder: type[json.JSONEncoder] = ..., decoder: type[json.JSONDecoder] = ..., @@ -59,7 +61,7 @@ class JSONField(CheckFieldDefaultMixin, Field[_A | Combinable, _A]): max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: Any | Callable[[], Any] = ..., editable: bool = ..., diff --git a/django-stubs/db/models/fields/related.pyi b/django-stubs/db/models/fields/related.pyi index 28f9042cd..758ef63ec 100644 --- a/django-stubs/db/models/fields/related.pyi +++ b/django-stubs/db/models/fields/related.pyi @@ -86,6 +86,7 @@ class ForeignObject(Generic[_M], RelatedField[_M, _M]): on_delete: _OnDeleteOptions, from_fields: Sequence[str], to_fields: Sequence[str], + *, rel: ForeignObjectRel | None = ..., related_name: str | None = ..., related_query_name: str | None = ..., @@ -99,7 +100,7 @@ class ForeignObject(Generic[_M], RelatedField[_M, _M]): max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _M | Callable[[], _M] | None = ..., editable: bool = ..., @@ -122,6 +123,7 @@ class ForeignObject(Generic[_M], RelatedField[_M, _M]): on_delete: _OnDeleteOptions, from_fields: Sequence[str], to_fields: Sequence[str], + *, rel: ForeignObjectRel | None = ..., related_name: str | None = ..., related_query_name: str | None = ..., @@ -135,7 +137,7 @@ class ForeignObject(Generic[_M], RelatedField[_M, _M]): max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _M | Callable[[], _M] = ..., editable: bool = ..., @@ -163,6 +165,7 @@ class ForeignKey(Generic[_M], ForeignObject[_M]): cls, to: type[_M] | str, on_delete: _OnDeleteOptions, + *, to_field: str | None = ..., related_name: str | None = ..., related_query_name: str | None = ..., @@ -176,7 +179,7 @@ class ForeignKey(Generic[_M], ForeignObject[_M]): max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _M | Callable[[], _M] | None = ..., editable: bool = ..., @@ -197,6 +200,7 @@ class ForeignKey(Generic[_M], ForeignObject[_M]): cls, to: type[_M] | str, on_delete: _OnDeleteOptions, + *, to_field: str | None = ..., related_name: str | None = ..., related_query_name: str | None = ..., @@ -210,7 +214,7 @@ class ForeignKey(Generic[_M], ForeignObject[_M]): max_length: int | None = ..., unique: bool = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _M | Callable[[], _M] = ..., editable: bool = ..., @@ -247,6 +251,7 @@ class OneToOneField(Generic[_M], ForeignKey[_M]): cls, to: type[_M] | str, on_delete: _OnDeleteOptions, + *, to_field: str | None = ..., related_name: str | None = ..., related_query_name: str | None = ..., @@ -260,7 +265,7 @@ class OneToOneField(Generic[_M], ForeignKey[_M]): max_length: int | None = ..., unique: Literal[True] = ..., blank: bool = ..., - null: Literal[False] = ..., + null: Literal[False] = False, db_index: bool = ..., default: _M | Callable[[], _M] | None = ..., editable: bool = ..., @@ -281,6 +286,7 @@ class OneToOneField(Generic[_M], ForeignKey[_M]): cls, to: type[_M] | str, on_delete: _OnDeleteOptions, + *, to_field: str | None = ..., related_name: str | None = ..., related_query_name: str | None = ..., @@ -294,7 +300,7 @@ class OneToOneField(Generic[_M], ForeignKey[_M]): max_length: int | None = ..., unique: Literal[True] = ..., blank: bool = ..., - null: Literal[True] = ..., + null: Literal[True], db_index: bool = ..., default: _M | Callable[[], _M] = ..., editable: bool = ..., From 419396ab5464cbc2ce24d6128d6dc6283c8898ca Mon Sep 17 00:00:00 2001 From: Karataev Pavel Date: Fri, 30 Aug 2024 02:58:40 +0300 Subject: [PATCH 2/5] Update tests for pyright 1.1.378 --- tests/pyright/test_arrays.py | 8 ++++---- tests/pyright/test_fields.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/pyright/test_arrays.py b/tests/pyright/test_arrays.py index dc4d9e099..d9b53bda1 100644 --- a/tests/pyright/test_arrays.py +++ b/tests/pyright/test_arrays.py @@ -34,7 +34,7 @@ class Foo(models.Model): ), Result( type="error", - message='Cannot assign member "array" for type "Foo"', + message='Cannot assign to attribute "array" for class "Foo"', line=13, column=3, ), @@ -82,7 +82,7 @@ class Foo(models.Model): ), Result( type="error", - message='Cannot assign member "array" for type "Foo"', + message='Cannot assign to attribute "array" for class "Foo"', line=15, column=3, ), @@ -133,7 +133,7 @@ class Foo(models.Model): ), Result( type="error", - message='Cannot assign member "array" for type "Foo"', + message='Cannot assign to attribute "array" for class "Foo"', line=18, column=3, ), @@ -197,7 +197,7 @@ class Foo(models.Model): ), Result( type="error", - message='Cannot assign member "array" for type "Foo"', + message='Cannot assign to attribute "array" for class "Foo"', line=19, column=3, ), diff --git a/tests/pyright/test_fields.py b/tests/pyright/test_fields.py index ce43a04fb..2358ff7d6 100644 --- a/tests/pyright/test_fields.py +++ b/tests/pyright/test_fields.py @@ -32,7 +32,7 @@ class Foo(models.Model): ), Result( type="error", - message='Cannot assign member "integer_with_choices" for type "Foo"', + message='Cannot assign to attribute "integer_with_choices" for class "Foo"', line=15, column=3, ), @@ -103,7 +103,7 @@ class Foo(models.Model): ), Result( type="error", - message='Cannot assign member "char_with_choices" for type "Foo"', + message='Cannot assign to attribute "char_with_choices" for class "Foo"', line=15, column=3, ), From d7945ab1d96895e9c59020ca77d90d379314940b Mon Sep 17 00:00:00 2001 From: Karataev Pavel Date: Fri, 30 Aug 2024 02:59:37 +0300 Subject: [PATCH 3/5] Lock pyright version to 1.1.378 --- package.json | 2 +- yarn.lock | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 3126547b8..9526b74ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "devDependencies": { - "pyright": "1.1.324" + "pyright": "1.1.378" }, "volta": { "node": "18.15.0" diff --git a/yarn.lock b/yarn.lock index 936e50ff4..8fe0d0469 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,14 +2,14 @@ # yarn lockfile v1 -fsevents@~2.3.2: +fsevents@~2.3.3: version "2.3.3" resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.3.tgz#cac6407785d03675a2a5e1a5305c697b347d90d6" integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw== -pyright@1.1.324: - version "1.1.324" - resolved "https://registry.yarnpkg.com/pyright/-/pyright-1.1.324.tgz#6a964835c0e1aabf039cb35d8587e0d9ce7b37bf" - integrity sha512-/Ng8G2Gb17dzQEHKgPa+Z5a6LPCLYNA4BVno1UdpDjnC9iLw0VAn5k/RNuaGkB/mhA82lV0OBcd5JEdaWcA3qg== +pyright@1.1.378: + version "1.1.378" + resolved "https://registry.yarnpkg.com/pyright/-/pyright-1.1.378.tgz#bb20dd59c4231ad9eeed77ac50edf1678f291554" + integrity sha512-lCDJUtcUGDYXOASd27WFxSM0qls/3kvblUsuWqSP+4l7z8JKgAMNRhUEw3s7h1JiRqruKi4SMMn/btgj5ZmnzA== optionalDependencies: - fsevents "~2.3.2" + fsevents "~2.3.3" From 66d7ad1db37e2fa50a6de0a7db8fc245f84beb36 Mon Sep 17 00:00:00 2001 From: Karataev Pavel Date: Fri, 30 Aug 2024 03:11:20 +0300 Subject: [PATCH 4/5] Remove 'type: ignore' from models.db.Field.__new__, mypy fixed in previous commit. --- .../contrib/postgres/fields/array.pyi | 2 +- django-stubs/db/models/fields/__init__.pyi | 42 +++++++++---------- django-stubs/db/models/fields/json.pyi | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/django-stubs/contrib/postgres/fields/array.pyi b/django-stubs/contrib/postgres/fields/array.pyi index f23f74eba..383e110c1 100644 --- a/django-stubs/contrib/postgres/fields/array.pyi +++ b/django-stubs/contrib/postgres/fields/array.pyi @@ -17,7 +17,7 @@ class ArrayField(CheckFieldDefaultMixin, Generic[_V], Field[_V | Combinable, _V] from_db_value: Any = ... base_field: Field[_V, _V] = ... @overload - def __new__( # type: ignore [misc] + def __new__( cls, base_field: Field[Any, _V], size: int | None = ..., diff --git a/django-stubs/db/models/fields/__init__.pyi b/django-stubs/db/models/fields/__init__.pyi index 1b5adb84b..f5ab40673 100644 --- a/django-stubs/db/models/fields/__init__.pyi +++ b/django-stubs/db/models/fields/__init__.pyi @@ -114,7 +114,7 @@ _I = TypeVar("_I", bound=int | None) class IntegerField(Generic[_I], Field[_I | Combinable, _I]): @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -173,7 +173,7 @@ class PositiveIntegerRelDbTypeMixin: class PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I]): @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -284,7 +284,7 @@ class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I]) class SmallIntegerField(IntegerField[_I]): @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -340,7 +340,7 @@ class SmallIntegerField(IntegerField[_I]): class BigIntegerField(IntegerField[_I]): @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -396,7 +396,7 @@ class BigIntegerField(IntegerField[_I]): class PositiveBigIntegerField(IntegerField[_I]): @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -454,7 +454,7 @@ _F = TypeVar("_F", bound=float | None) class FloatField(Generic[_F], Field[_F | Combinable, _F]): @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -515,7 +515,7 @@ class DecimalField(Generic[_DEC], Field[_DEC | Combinable, _DEC]): max_digits: int = ... decimal_places: int = ... @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -677,7 +677,7 @@ _C = TypeVar("_C", bound=str | None) class CharField(Generic[_C], Field[_C | Combinable, _C]): @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -737,7 +737,7 @@ class CharField(Generic[_C], Field[_C | Combinable, _C]): class SlugField(CharField[_C]): @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -797,7 +797,7 @@ class SlugField(CharField[_C]): class EmailField(CharField[_C]): @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -855,7 +855,7 @@ class EmailField(CharField[_C]): class URLField(CharField[_C]): @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -913,7 +913,7 @@ class URLField(CharField[_C]): class TextField(Generic[_C], Field[_C | Combinable, _C]): @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -1030,7 +1030,7 @@ class BooleanField(Generic[_B], Field[_B | Combinable, _B]): class IPAddressField(Generic[_C], Field[_C | Combinable, _C]): @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -1089,7 +1089,7 @@ class GenericIPAddressField( Field[_C | ipaddress.IPv4Address | ipaddress.IPv6Address | Combinable, _C], ): @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -1156,7 +1156,7 @@ class DateField(DateTimeCheckMixin, Field[_DD | Combinable, _DD]): auto_now: bool = ... auto_now_add: bool = ... @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -1225,7 +1225,7 @@ class TimeField(Generic[_TM], DateTimeCheckMixin, Field[_TM | Combinable, _TM]): auto_now: bool = ... auto_now_add: bool = ... @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -1294,7 +1294,7 @@ class DateTimeField(DateField[_DT]): auto_now: bool = ... auto_now_add: bool = ... @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -1360,7 +1360,7 @@ _U = TypeVar("_U", bound=uuid.UUID | None) class UUIDField(Generic[_U], Field[str | _U, _U]): @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -1421,7 +1421,7 @@ class FilePathField(Generic[_C], Field[_C, _C]): allow_files: bool = ... allow_folders: bool = ... @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -1489,7 +1489,7 @@ _BIN = TypeVar("_BIN", bound=bytes | None) class BinaryField(Generic[_BIN], Field[_BIN | bytearray | memoryview, _BIN]): @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, @@ -1551,7 +1551,7 @@ _TD = TypeVar("_TD", bound=timedelta | None) class DurationField(Generic[_TD], Field[_TD, _TD]): @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, diff --git a/django-stubs/db/models/fields/json.pyi b/django-stubs/db/models/fields/json.pyi index 2ef86ad09..936507e99 100644 --- a/django-stubs/db/models/fields/json.pyi +++ b/django-stubs/db/models/fields/json.pyi @@ -20,7 +20,7 @@ class JSONField(CheckFieldDefaultMixin, Field[_A | Combinable, _A]): def get_transform(self, name: Any) -> Any: ... def value_to_string(self, obj: Any) -> Any: ... @overload - def __new__( # type: ignore [misc] + def __new__( cls, verbose_name: str | None = ..., *, From 8f2dccb19851302fc0992d456e7e43f3e89e6820 Mon Sep 17 00:00:00 2001 From: Karataev Pavel Date: Fri, 30 Aug 2024 03:59:18 +0300 Subject: [PATCH 5/5] Add a bunch of 'pyright: ignore' for django-stubs/ --- .../contrib/admin/templatetags/base.pyi | 2 +- django-stubs/contrib/contenttypes/fields.pyi | 2 +- django-stubs/contrib/contenttypes/models.pyi | 4 +- django-stubs/core/files/base.pyi | 2 +- django-stubs/core/mail/message.pyi | 12 +++--- django-stubs/core/serializers/json.pyi | 2 +- django-stubs/core/servers/basehttp.pyi | 4 +- django-stubs/db/models/fields/files.pyi | 4 +- django-stubs/db/models/fields/related.pyi | 40 +++++++++++++------ .../db/models/fields/related_descriptors.pyi | 6 +-- django-stubs/http/cookie.pyi | 2 +- django-stubs/http/response.pyi | 2 +- django-stubs/template/context.pyi | 4 +- django-stubs/template/response.pyi | 6 +-- django-stubs/test/client.pyi | 2 +- django-stubs/utils/log.pyi | 2 +- django-stubs/utils/six.pyi | 2 +- django-stubs/views/decorators/csrf.pyi | 2 +- 18 files changed, 59 insertions(+), 41 deletions(-) diff --git a/django-stubs/contrib/admin/templatetags/base.pyi b/django-stubs/contrib/admin/templatetags/base.pyi index ca38fe4cf..ea10ef436 100644 --- a/django-stubs/contrib/admin/templatetags/base.pyi +++ b/django-stubs/contrib/admin/templatetags/base.pyi @@ -10,7 +10,7 @@ class InclusionAdminNode(InclusionNode): args: list[Any] func: Callable[..., Any] kwargs: dict[Any, Any] - takes_context: bool + takes_context: bool # pyright: ignore[reportIncompatibleVariableOverride] template_name: str = ... def __init__( self, diff --git a/django-stubs/contrib/contenttypes/fields.pyi b/django-stubs/contrib/contenttypes/fields.pyi index ea6b5565a..33a5102cb 100644 --- a/django-stubs/contrib/contenttypes/fields.pyi +++ b/django-stubs/contrib/contenttypes/fields.pyi @@ -67,7 +67,7 @@ class GenericForeignKey(FieldCacheMixin): def __set__(self, instance: Model, value: Any | None) -> None: ... class GenericRel(ForeignObjectRel): - field: GenericRelation + field: GenericRelation # pyright: ignore[reportIncompatibleVariableOverride] def __init__( self, field: GenericRelation, diff --git a/django-stubs/contrib/contenttypes/models.pyi b/django-stubs/contrib/contenttypes/models.pyi index 69af4dadb..289b7ccf7 100644 --- a/django-stubs/contrib/contenttypes/models.pyi +++ b/django-stubs/contrib/contenttypes/models.pyi @@ -22,7 +22,9 @@ class ContentType(models.Model): id: int app_label: models.CharField[Any] = ... model: models.CharField[Any] = ... - objects: ClassVar[ContentTypeManager] = ... + objects: ClassVar[ # pyright: ignore[reportIncompatibleVariableOverride] + ContentTypeManager + ] = ... permission_set: Manager[Permission] @property def name(self) -> str: ... diff --git a/django-stubs/core/files/base.pyi b/django-stubs/core/files/base.pyi index 91f2632f3..632e6d0dd 100644 --- a/django-stubs/core/files/base.pyi +++ b/django-stubs/core/files/base.pyi @@ -31,7 +31,7 @@ class File(FileProxyMixin, IO[Any]): def close(self) -> None: ... class ContentFile(File): - file: StringIO + file: StringIO # pyright: ignore[reportIncompatibleVariableOverride] size: Any = ... def __init__(self, content: bytes | str, name: str | None = ...) -> None: ... def write(self, data: str) -> int: ... # type: ignore[override] diff --git a/django-stubs/core/mail/message.pyi b/django-stubs/core/mail/message.pyi index a2ae5708c..4554a8031 100644 --- a/django-stubs/core/mail/message.pyi +++ b/django-stubs/core/mail/message.pyi @@ -26,15 +26,15 @@ class MIMEMixin: ... class SafeMIMEMessage(MIMEMixin, MIMEMessage): defects: list[Any] - epilogue: None + epilogue: None # pyright: ignore[reportIncompatibleVariableOverride] policy: Policy # type: ignore [no-any-unimported] - preamble: None + preamble: None # pyright: ignore[reportIncompatibleVariableOverride] class SafeMIMEText(MIMEMixin, MIMEText): defects: list[Any] - epilogue: None + epilogue: None # pyright: ignore[reportIncompatibleVariableOverride] policy: Policy # type: ignore [no-any-unimported] - preamble: None + preamble: None # pyright: ignore[reportIncompatibleVariableOverride] encoding: str = ... def __init__( self, _text: str, _subtype: str = ..., _charset: str = ... @@ -42,9 +42,9 @@ class SafeMIMEText(MIMEMixin, MIMEText): class SafeMIMEMultipart(MIMEMixin, MIMEMultipart): defects: list[Any] - epilogue: None + epilogue: None # pyright: ignore[reportIncompatibleVariableOverride] policy: Policy # type: ignore [no-any-unimported] - preamble: None + preamble: None # pyright: ignore[reportIncompatibleVariableOverride] encoding: str = ... def __init__( self, diff --git a/django-stubs/core/serializers/json.pyi b/django-stubs/core/serializers/json.pyi index 17bd23547..56fd5bb82 100644 --- a/django-stubs/core/serializers/json.pyi +++ b/django-stubs/core/serializers/json.pyi @@ -12,6 +12,6 @@ class DjangoJSONEncoder(json.JSONEncoder): allow_nan: bool check_circular: bool ensure_ascii: bool - indent: int + indent: int # pyright: ignore[reportIncompatibleVariableOverride] skipkeys: bool sort_keys: bool diff --git a/django-stubs/core/servers/basehttp.pyi b/django-stubs/core/servers/basehttp.pyi index f659f0d58..b6f03ee6b 100644 --- a/django-stubs/core/servers/basehttp.pyi +++ b/django-stubs/core/servers/basehttp.pyi @@ -28,8 +28,8 @@ class WSGIRequestHandler(simple_server.WSGIRequestHandler): close_connection: bool connection: WSGIRequest request: WSGIRequest - rfile: BytesIO - wfile: BytesIO + rfile: BytesIO # pyright: ignore[reportIncompatibleVariableOverride] + wfile: BytesIO # pyright: ignore[reportIncompatibleVariableOverride] protocol_version: str = ... def address_string(self) -> str: ... def log_message(self, format: str, *args: Any) -> None: ... diff --git a/django-stubs/db/models/fields/files.pyi b/django-stubs/db/models/fields/files.pyi index af93c1f78..d28d763c9 100644 --- a/django-stubs/db/models/fields/files.pyi +++ b/django-stubs/db/models/fields/files.pyi @@ -81,11 +81,11 @@ class FileField(Field[FileDescriptor, FileDescriptor]): def generate_filename(self, instance: Model | None, filename: str) -> str: ... class ImageFileDescriptor(FileDescriptor): - field: ImageField + field: ImageField # pyright: ignore[reportIncompatibleVariableOverride] def __set__(self, instance: Model, value: str | None) -> None: ... class ImageFieldFile(ImageFile, FieldFile): - field: ImageField + field: ImageField # pyright: ignore[reportIncompatibleVariableOverride] def delete(self, save: bool = ...) -> None: ... class ImageField(FileField): diff --git a/django-stubs/db/models/fields/related.pyi b/django-stubs/db/models/fields/related.pyi index 758ef63ec..d214ac09a 100644 --- a/django-stubs/db/models/fields/related.pyi +++ b/django-stubs/db/models/fields/related.pyi @@ -54,10 +54,10 @@ _ErrorMessagesToOverride = dict[str, Any] RECURSIVE_RELATIONSHIP_CONSTANT: str = ... class RelatedField(FieldCacheMixin, Generic[_ST, _GT], Field[_ST, _GT]): - one_to_many: bool = ... - one_to_one: bool = ... - many_to_many: bool = ... - many_to_one: bool = ... + one_to_many: bool = ... # pyright: ignore[reportIncompatibleVariableOverride] + one_to_one: bool = ... # pyright: ignore[reportIncompatibleVariableOverride] + many_to_many: bool = ... # pyright: ignore[reportIncompatibleVariableOverride] + many_to_one: bool = ... # pyright: ignore[reportIncompatibleVariableOverride] related_model: type[_GT] = ... opts: Any = ... def get_forward_related_filter(self, obj: Model) -> dict[str, int | UUID]: ... @@ -74,10 +74,18 @@ class RelatedField(FieldCacheMixin, Generic[_ST, _GT], Field[_ST, _GT]): _M = TypeVar("_M", bound=Model | None) class ForeignObject(Generic[_M], RelatedField[_M, _M]): - one_to_many: Literal[False] = ... - one_to_one: Literal[False] = ... - many_to_many: Literal[False] = ... - many_to_one: Literal[True] = ... + one_to_many: Literal[ # pyright: ignore[reportIncompatibleVariableOverride] + False + ] = ... + one_to_one: Literal[ # pyright: ignore[reportIncompatibleVariableOverride] + False + ] = ... + many_to_many: Literal[ # pyright: ignore[reportIncompatibleVariableOverride] + False + ] = ... + many_to_one: Literal[ # pyright: ignore[reportIncompatibleVariableOverride] + True + ] = ... related_model: type[_M] = ... @overload def __new__( @@ -332,10 +340,18 @@ _MN = TypeVar("_MN", bound=Model) class ManyToManyField( Generic[_MM, _MN], RelatedField[Sequence[_MN], ManyToManyRelatedManager[_MM, _MN]] ): - one_to_many: Literal[False] = ... - one_to_one: Literal[False] = ... - many_to_many: Literal[True] = ... - many_to_one: Literal[False] = ... + one_to_many: Literal[ # pyright: ignore[reportIncompatibleVariableOverride] + False + ] = ... + one_to_one: Literal[ # pyright: ignore[reportIncompatibleVariableOverride] + False + ] = ... + many_to_many: Literal[ # pyright: ignore[reportIncompatibleVariableOverride] + True + ] = ... + many_to_one: Literal[ # pyright: ignore[reportIncompatibleVariableOverride] + False + ] = ... rel_class: Any = ... description: Any = ... has_null_arg: Any = ... diff --git a/django-stubs/db/models/fields/related_descriptors.pyi b/django-stubs/db/models/fields/related_descriptors.pyi index bbc9d8bb4..e3dcdddce 100644 --- a/django-stubs/db/models/fields/related_descriptors.pyi +++ b/django-stubs/db/models/fields/related_descriptors.pyi @@ -31,7 +31,7 @@ class ForwardManyToOneDescriptor: class ForwardOneToOneDescriptor(ForwardManyToOneDescriptor): RelatedObjectDoesNotExist: type[ObjectDoesNotExist] - field: OneToOneField[Any] + field: OneToOneField[Any] # pyright: ignore[reportIncompatibleVariableOverride] def get_object(self, instance: Model) -> Model: ... class ReverseOneToOneDescriptor: @@ -64,8 +64,8 @@ class ReverseManyToOneDescriptor: def create_reverse_many_to_one_manager(superclass: Any, rel: Any) -> Any: ... class ManyToManyDescriptor(ReverseManyToOneDescriptor): - field: RelatedField[Any, Any] - rel: ManyToManyRel + field: RelatedField[Any, Any] # pyright: ignore[reportIncompatibleVariableOverride] + rel: ManyToManyRel # pyright: ignore[reportIncompatibleVariableOverride] reverse: bool = ... def __init__(self, rel: ManyToManyRel, reverse: bool = ...) -> None: ... @property diff --git a/django-stubs/http/cookie.pyi b/django-stubs/http/cookie.pyi index 2f9214ac0..32bd0b02e 100644 --- a/django-stubs/http/cookie.pyi +++ b/django-stubs/http/cookie.pyi @@ -1,5 +1,5 @@ from http import cookies -SimpleCookie = cookies.SimpleCookie[str] +SimpleCookie = cookies.SimpleCookie def parse_cookie(cookie: str) -> dict[str, str]: ... diff --git a/django-stubs/http/response.pyi b/django-stubs/http/response.pyi index 6ae141546..6c45bcca1 100644 --- a/django-stubs/http/response.pyi +++ b/django-stubs/http/response.pyi @@ -19,7 +19,7 @@ class ResponseHeaders(CaseInsensitiveMapping[str]): class BadHeaderError(ValueError): ... class HttpResponseBase: - cookies: SimpleCookie + cookies: SimpleCookie # type: ignore [type-arg] headers: ResponseHeaders status_code: int closed: bool diff --git a/django-stubs/template/context.pyi b/django-stubs/template/context.pyi index 9f5466d2f..7b25f73fd 100644 --- a/django-stubs/template/context.pyi +++ b/django-stubs/template/context.pyi @@ -68,8 +68,8 @@ class RequestContext(Context): dicts: list[dict[str, str]] render_context: RenderContext template_name: str | None - use_l10n: None - use_tz: None + use_l10n: None # pyright: ignore[reportIncompatibleVariableOverride] + use_tz: None # pyright: ignore[reportIncompatibleVariableOverride] request: HttpRequest = ... def __init__( self, diff --git a/django-stubs/template/response.pyi b/django-stubs/template/response.pyi index 750640adf..86dfa9b7c 100644 --- a/django-stubs/template/response.pyi +++ b/django-stubs/template/response.pyi @@ -15,7 +15,7 @@ class ContentNotRenderedError(Exception): ... class SimpleTemplateResponse(HttpResponse): content: Any = ... closed: bool - cookies: SimpleCookie[Any] + cookies: SimpleCookie # type: ignore [type-arg] status_code: int rendering_attrs: Any = ... template_name: list[str] | Template | str = ... @@ -47,9 +47,9 @@ class SimpleTemplateResponse(HttpResponse): class TemplateResponse(SimpleTemplateResponse): client: Client closed: bool - context: RequestContext + context: RequestContext # pyright: ignore[reportIncompatibleVariableOverride] context_data: dict[str, Any] | None - cookies: SimpleCookie[Any] + cookies: SimpleCookie # type: ignore [type-arg] csrf_cookie_set: bool json: functools.partial[Any] redirect_chain: list[tuple[str, int]] diff --git a/django-stubs/test/client.pyi b/django-stubs/test/client.pyi index 279523c94..76bdc685b 100644 --- a/django-stubs/test/client.pyi +++ b/django-stubs/test/client.pyi @@ -52,7 +52,7 @@ _RequestData = Any | None class RequestFactory: json_encoder: type[JSONEncoder] defaults: dict[str, str] - cookies: SimpleCookie + cookies: SimpleCookie # type: ignore [type-arg] errors: BytesIO def __init__( self, diff --git a/django-stubs/utils/log.pyi b/django-stubs/utils/log.pyi index 61c0bf711..c5efafb60 100644 --- a/django-stubs/utils/log.pyi +++ b/django-stubs/utils/log.pyi @@ -36,7 +36,7 @@ class RequireDebugTrue(logging.Filter): def filter(self, record: str | LogRecord) -> bool: ... class ServerFormatter(logging.Formatter): - datefmt: None + datefmt: None # pyright: ignore[reportIncompatibleVariableOverride] style: Style = ... def __init__(self, *args: Any, **kwargs: Any) -> None: ... def uses_server_time(self) -> bool: ... diff --git a/django-stubs/utils/six.pyi b/django-stubs/utils/six.pyi index 381d068ce..e6b386279 100644 --- a/django-stubs/utils/six.pyi +++ b/django-stubs/utils/six.pyi @@ -43,7 +43,7 @@ def get_method_function(meth: types.MethodType) -> types.FunctionType: ... def get_method_self(meth: types.MethodType) -> object | None: ... def get_function_closure( fun: types.FunctionType, -) -> tuple[types._Cell, ...] | None: ... +) -> tuple[types._Cell, ...] | None: ... # pyright: ignore[reportAttributeAccessIssue] def get_function_code(fun: types.FunctionType) -> types.CodeType: ... def get_function_defaults(fun: types.FunctionType) -> tuple[Any, ...] | None: ... def get_function_globals(fun: types.FunctionType) -> dict[str, Any]: ... diff --git a/django-stubs/views/decorators/csrf.pyi b/django-stubs/views/decorators/csrf.pyi index a7b2f5fc1..32d5dcd26 100644 --- a/django-stubs/views/decorators/csrf.pyi +++ b/django-stubs/views/decorators/csrf.pyi @@ -12,7 +12,7 @@ class _EnsureCsrfToken(CsrfViewMiddleware): ... def requires_csrf_token(__view: _F) -> _F: ... class _EnsureCsrfCookie(CsrfViewMiddleware): - get_response: None + get_response: None # pyright: ignore[reportIncompatibleVariableOverride] def process_view( self, request: Any, callback: Any, callback_args: Any, callback_kwargs: Any ) -> Any: ...