Skip to content

Commit

Permalink
Add BaseConstraint.violation_error_code (#1969)
Browse files Browse the repository at this point in the history
  • Loading branch information
q0w authored Feb 24, 2024
1 parent 14005c8 commit 2dcf1bf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions django-stubs/contrib/postgres/constraints.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ class ExclusionConstraint(BaseConstraint):
deferrable: Deferrable | None = ...,
include: list[str] | tuple[str] | None = ...,
opclasses: list[str] | tuple[str] = ...,
violation_error_code: str | None = ...,
violation_error_message: _StrOrPromise | None = ...,
) -> None: ...
9 changes: 8 additions & 1 deletion django-stubs/db/models/constraints.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Deferrable(Enum):

class BaseConstraint:
name: str
violation_error_code: str | None
violation_error_message: _StrOrPromise | None
default_violation_error_message: _StrOrPromise
def __init__(self, name: str, violation_error_message: _StrOrPromise | None = ...) -> None: ...
Expand All @@ -27,7 +28,12 @@ class BaseConstraint:
class CheckConstraint(BaseConstraint):
check: Q | BaseExpression
def __init__(
self, *, check: Q | BaseExpression, name: str, violation_error_message: _StrOrPromise | None = ...
self,
*,
check: Q | BaseExpression,
name: str,
violation_error_code: str | None = ...,
violation_error_message: _StrOrPromise | None = ...,
) -> None: ...

class UniqueConstraint(BaseConstraint):
Expand All @@ -46,6 +52,7 @@ class UniqueConstraint(BaseConstraint):
deferrable: Deferrable | None = ...,
include: Sequence[str] | None = ...,
opclasses: Sequence[Any] = ...,
violation_error_code: str | None = ...,
violation_error_message: _StrOrPromise | None = ...,
) -> None: ...
@overload
Expand Down
6 changes: 0 additions & 6 deletions scripts/stubtest/allowlist_todo_django50.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ django.contrib.gis.admin.options.spherical_mercator_srid
django.contrib.gis.admin.widgets
django.contrib.gis.db.backends.spatialite.schema.SpatialiteSchemaEditor.alter_db_table
django.contrib.gis.db.models.BaseConstraint.__init__
django.contrib.gis.db.models.BaseConstraint.violation_error_code
django.contrib.gis.db.models.Case.allowed_default
django.contrib.gis.db.models.CheckConstraint.__init__
django.contrib.gis.db.models.ExpressionWrapper.allowed_default
django.contrib.gis.db.models.F.allowed_default
django.contrib.gis.db.models.Field.__init__
Expand Down Expand Up @@ -160,9 +158,7 @@ django.db.backends.sqlite3.schema.DatabaseSchemaEditor.sql_alter_table_comment
django.db.backends.utils.CursorWrapper.APPS_NOT_READY_WARNING_MSG
django.db.migrations.serializer.BaseUnorderedSequenceSerializer
django.db.models.BaseConstraint.__init__
django.db.models.BaseConstraint.violation_error_code
django.db.models.Case.allowed_default
django.db.models.CheckConstraint.__init__
django.db.models.ExpressionWrapper.allowed_default
django.db.models.F.allowed_default
django.db.models.Field.__init__
Expand All @@ -183,8 +179,6 @@ django.db.models.QuerySet.update_or_create
django.db.models.Value.allowed_default
django.db.models.When.allowed_default
django.db.models.constraints.BaseConstraint.__init__
django.db.models.constraints.BaseConstraint.violation_error_code
django.db.models.constraints.CheckConstraint.__init__
django.db.models.expressions.BaseExpression.allowed_default
django.db.models.expressions.Case.allowed_default
django.db.models.expressions.CombinedExpression.allowed_default
Expand Down

0 comments on commit 2dcf1bf

Please sign in to comment.