Skip to content

Commit 9eea0a3

Browse files
authored
Pass positional arguments name and violation_error_message to BaseConstraint (#1974)
1 parent 6293e6d commit 9eea0a3

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

django-stubs/db/models/constraints.pyi

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ from django.db.models.base import Model
77
from django.db.models.expressions import BaseExpression, Combinable
88
from django.db.models.query_utils import Q
99
from django.utils.functional import _StrOrPromise
10-
from typing_extensions import Self
10+
from typing_extensions import Self, deprecated
1111

1212
class Deferrable(Enum):
1313
DEFERRED: str
@@ -18,8 +18,18 @@ class BaseConstraint:
1818
violation_error_code: str | None
1919
violation_error_message: _StrOrPromise | None
2020
default_violation_error_message: _StrOrPromise
21+
@overload
22+
def __init__(
23+
self, *, name: str, violation_error_code: str | None = ..., violation_error_message: _StrOrPromise | None = ...
24+
) -> None: ...
25+
@overload
26+
@deprecated("Passing positional arguments to BaseConstraint is deprecated and will be removed in Django 6.0")
2127
def __init__(
22-
self, name: str, violation_error_code: str | None = ..., violation_error_message: _StrOrPromise | None = ...
28+
self,
29+
*args: Any,
30+
name: str | None = ...,
31+
violation_error_code: str | None = ...,
32+
violation_error_message: _StrOrPromise | None = ...,
2333
) -> None: ...
2434
def constraint_sql(self, model: type[Model] | None, schema_editor: BaseDatabaseSchemaEditor | None) -> str: ...
2535
def create_sql(self, model: type[Model] | None, schema_editor: BaseDatabaseSchemaEditor | None) -> str: ...

scripts/stubtest/allowlist_todo_django50.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ django.contrib.gis.admin.OpenLayersWidget
4545
django.contrib.gis.admin.options.spherical_mercator_srid
4646
django.contrib.gis.admin.widgets
4747
django.contrib.gis.db.backends.spatialite.schema.SpatialiteSchemaEditor.alter_db_table
48-
django.contrib.gis.db.models.BaseConstraint.__init__
4948
django.contrib.gis.db.models.Case.allowed_default
5049
django.contrib.gis.db.models.ExpressionWrapper.allowed_default
5150
django.contrib.gis.db.models.F.allowed_default
@@ -149,7 +148,6 @@ django.db.backends.sqlite3.schema.DatabaseSchemaEditor.sql_alter_column_comment
149148
django.db.backends.sqlite3.schema.DatabaseSchemaEditor.sql_alter_table_comment
150149
django.db.backends.utils.CursorWrapper.APPS_NOT_READY_WARNING_MSG
151150
django.db.migrations.serializer.BaseUnorderedSequenceSerializer
152-
django.db.models.BaseConstraint.__init__
153151
django.db.models.Case.allowed_default
154152
django.db.models.ExpressionWrapper.allowed_default
155153
django.db.models.F.allowed_default
@@ -168,7 +166,6 @@ django.db.models.Prefetch.get_current_querysets
168166
django.db.models.Q.identity
169167
django.db.models.Value.allowed_default
170168
django.db.models.When.allowed_default
171-
django.db.models.constraints.BaseConstraint.__init__
172169
django.db.models.expressions.BaseExpression.allowed_default
173170
django.db.models.expressions.Case.allowed_default
174171
django.db.models.expressions.CombinedExpression.allowed_default

0 commit comments

Comments
 (0)