Skip to content

Commit

Permalink
django-stubs.db.models.fields: add db_comment in constructors (#250)
Browse files Browse the repository at this point in the history
This commit adds the db-comment attribute to the Field class and to the constructor of Fields.

The attribute was added in Django 4.2: https://docs.djangoproject.com/fr/5.0/ref/models/fields/#db-comment.

We use it extensively in our codebase and this leads to currently making Fields untypable for us.

Hope this helps.
  • Loading branch information
florentinl authored Jun 14, 2024
1 parent bf20ead commit 4ced894
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions django-stubs/db/models/fields/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class Field(RegisterLookupMixin, Generic[_ST, _GT]):
empty_strings_allowed: bool = ...
choices: _FieldChoices = ...
db_column: str | None
db_comment: str | None
column: str
default: Any
error_messages: _ErrorMessagesToOverride
Expand Down Expand Up @@ -133,6 +134,7 @@ class IntegerField(Generic[_I], Field[_I | Combinable, _I]):
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand All @@ -158,6 +160,7 @@ class IntegerField(Generic[_I], Field[_I | Combinable, _I]):
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -188,6 +191,7 @@ class PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I]):
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand All @@ -213,6 +217,7 @@ class PositiveIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I]):
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -265,6 +270,7 @@ class PositiveSmallIntegerField(PositiveIntegerRelDbTypeMixin, IntegerField[_I])
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -292,6 +298,7 @@ class SmallIntegerField(IntegerField[_I]):
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand All @@ -317,6 +324,7 @@ class SmallIntegerField(IntegerField[_I]):
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -344,6 +352,7 @@ class BigIntegerField(IntegerField[_I]):
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand All @@ -369,6 +378,7 @@ class BigIntegerField(IntegerField[_I]):
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -396,6 +406,7 @@ class PositiveBigIntegerField(IntegerField[_I]):
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand All @@ -421,6 +432,7 @@ class PositiveBigIntegerField(IntegerField[_I]):
choices: Iterable[tuple[_I, str] | tuple[str, Iterable[tuple[_I, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -450,6 +462,7 @@ class FloatField(Generic[_F], Field[_F | Combinable, _F]):
choices: Iterable[tuple[_F, str] | tuple[str, Iterable[tuple[_F, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand All @@ -475,6 +488,7 @@ class FloatField(Generic[_F], Field[_F | Combinable, _F]):
choices: Iterable[tuple[_F, str] | tuple[str, Iterable[tuple[_F, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -511,6 +525,7 @@ class DecimalField(Generic[_DEC], Field[_DEC | Combinable, _DEC]):
] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -540,6 +555,7 @@ class DecimalField(Generic[_DEC], Field[_DEC | Combinable, _DEC]):
] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -573,6 +589,7 @@ class AutoField(AutoFieldMixin, IntegerField[int], metaclass=AutoFieldMeta):
] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -603,6 +620,7 @@ class BigAutoField(AutoFieldMixin, BigIntegerField[int]):
] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -633,6 +651,7 @@ class SmallAutoField(AutoFieldMixin, SmallIntegerField[int]):
] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -663,6 +682,7 @@ class CharField(Generic[_C], Field[_C | Combinable, _C]):
choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand All @@ -689,6 +709,7 @@ class CharField(Generic[_C], Field[_C | Combinable, _C]):
choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -717,6 +738,7 @@ class SlugField(CharField[_C]):
choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -744,6 +766,7 @@ class SlugField(CharField[_C]):
choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -773,6 +796,7 @@ class EmailField(CharField[_C]):
choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand All @@ -799,6 +823,7 @@ class EmailField(CharField[_C]):
choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -827,6 +852,7 @@ class URLField(CharField[_C]):
choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand All @@ -853,6 +879,7 @@ class URLField(CharField[_C]):
choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -881,6 +908,7 @@ class TextField(Generic[_C], Field[_C | Combinable, _C]):
choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand All @@ -907,6 +935,7 @@ class TextField(Generic[_C], Field[_C | Combinable, _C]):
choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -937,6 +966,7 @@ class BooleanField(Generic[_B], Field[_B | Combinable, _B]):
choices: Iterable[tuple[_B, str] | tuple[str, Iterable[tuple[_B, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -990,6 +1020,7 @@ class IPAddressField(Generic[_C], Field[_C | Combinable, _C]):
choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand All @@ -1015,6 +1046,7 @@ class IPAddressField(Generic[_C], Field[_C | Combinable, _C]):
choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -1047,6 +1079,7 @@ class GenericIPAddressField(
choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -1074,6 +1107,7 @@ class GenericIPAddressField(
choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -1112,6 +1146,7 @@ class DateField(DateTimeCheckMixin, Field[_DD | Combinable, _DD]):
] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -1141,6 +1176,7 @@ class DateField(DateTimeCheckMixin, Field[_DD | Combinable, _DD]):
] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -1177,6 +1213,7 @@ class TimeField(Generic[_TM], DateTimeCheckMixin, Field[_TM | Combinable, _TM]):
] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -1206,6 +1243,7 @@ class TimeField(Generic[_TM], DateTimeCheckMixin, Field[_TM | Combinable, _TM]):
] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -1242,6 +1280,7 @@ class DateTimeField(DateField[_DT]):
] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -1271,6 +1310,7 @@ class DateTimeField(DateField[_DT]):
] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -1300,6 +1340,7 @@ class UUIDField(Generic[_U], Field[str | _U, _U]):
choices: Iterable[tuple[_U, str] | tuple[str, Iterable[tuple[_U, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand All @@ -1325,6 +1366,7 @@ class UUIDField(Generic[_U], Field[str | _U, _U]):
choices: Iterable[tuple[_U, str] | tuple[str, Iterable[tuple[_U, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -1362,6 +1404,7 @@ class FilePathField(Generic[_C], Field[_C, _C]):
choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -1392,6 +1435,7 @@ class FilePathField(Generic[_C], Field[_C, _C]):
choices: Iterable[tuple[_C, str] | tuple[str, Iterable[tuple[_C, str]]]] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -1423,6 +1467,7 @@ class BinaryField(Generic[_BIN], Field[_BIN | bytearray | memoryview, _BIN]):
] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -1450,6 +1495,7 @@ class BinaryField(Generic[_BIN], Field[_BIN | bytearray | memoryview, _BIN]):
] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -1481,6 +1527,7 @@ class DurationField(Generic[_TD], Field[_TD, _TD]):
] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down Expand Up @@ -1508,6 +1555,7 @@ class DurationField(Generic[_TD], Field[_TD, _TD]):
] = ...,
help_text: str = ...,
db_column: str | None = ...,
db_comment: str | None = ...,
db_tablespace: str | None = ...,
validators: Iterable[_ValidatorCallable] = ...,
error_messages: _ErrorMessagesToOverride | None = ...,
Expand Down

0 comments on commit 4ced894

Please sign in to comment.