Skip to content

Commit f041b3f

Browse files
committed
Add BaseConstraint.violation_error_code
1 parent 7564f79 commit f041b3f

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

django-stubs/contrib/postgres/constraints.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ class ExclusionConstraint(BaseConstraint):
2020
deferrable: Deferrable | None = ...,
2121
include: list[str] | tuple[str] | None = ...,
2222
opclasses: list[str] | tuple[str] = ...,
23+
violation_error_code: str | None = ...,
2324
violation_error_message: _StrOrPromise | None = ...,
2425
) -> None: ...

django-stubs/db/models/constraints.pyi

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Deferrable(Enum):
1515

1616
class BaseConstraint:
1717
name: str
18+
violation_error_code: str | None
1819
violation_error_message: _StrOrPromise | None
1920
default_violation_error_message: _StrOrPromise
2021
def __init__(self, name: str, violation_error_message: _StrOrPromise | None = ...) -> None: ...
@@ -27,7 +28,12 @@ class BaseConstraint:
2728
class CheckConstraint(BaseConstraint):
2829
check: Q | BaseExpression
2930
def __init__(
30-
self, *, check: Q | BaseExpression, name: str, violation_error_message: _StrOrPromise | None = ...
31+
self,
32+
*,
33+
check: Q | BaseExpression,
34+
name: str,
35+
violation_error_code: str | None = ...,
36+
violation_error_message: _StrOrPromise | None = ...,
3137
) -> None: ...
3238

3339
class UniqueConstraint(BaseConstraint):
@@ -46,6 +52,7 @@ class UniqueConstraint(BaseConstraint):
4652
deferrable: Deferrable | None = ...,
4753
include: Sequence[str] | None = ...,
4854
opclasses: Sequence[Any] = ...,
55+
violation_error_code: str | None = ...,
4956
violation_error_message: _StrOrPromise | None = ...,
5057
) -> None: ...
5158
@overload

scripts/stubtest/allowlist_todo_django50.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ django.contrib.gis.admin.options.spherical_mercator_srid
5555
django.contrib.gis.admin.widgets
5656
django.contrib.gis.db.backends.spatialite.schema.SpatialiteSchemaEditor.alter_db_table
5757
django.contrib.gis.db.models.BaseConstraint.__init__
58-
django.contrib.gis.db.models.BaseConstraint.violation_error_code
5958
django.contrib.gis.db.models.Case.allowed_default
6059
django.contrib.gis.db.models.CheckConstraint.__init__
6160
django.contrib.gis.db.models.ExpressionWrapper.allowed_default
@@ -165,7 +164,6 @@ django.db.backends.sqlite3.schema.DatabaseSchemaEditor.sql_alter_table_comment
165164
django.db.backends.utils.CursorWrapper.APPS_NOT_READY_WARNING_MSG
166165
django.db.migrations.serializer.BaseUnorderedSequenceSerializer
167166
django.db.models.BaseConstraint.__init__
168-
django.db.models.BaseConstraint.violation_error_code
169167
django.db.models.Case.allowed_default
170168
django.db.models.CheckConstraint.__init__
171169
django.db.models.ExpressionWrapper.allowed_default
@@ -188,7 +186,6 @@ django.db.models.QuerySet.update_or_create
188186
django.db.models.Value.allowed_default
189187
django.db.models.When.allowed_default
190188
django.db.models.constraints.BaseConstraint.__init__
191-
django.db.models.constraints.BaseConstraint.violation_error_code
192189
django.db.models.constraints.CheckConstraint.__init__
193190
django.db.models.expressions.BaseExpression.allowed_default
194191
django.db.models.expressions.Case.allowed_default

0 commit comments

Comments
 (0)