From ead941f7f2f016ab04de4946a7dff1185c67602f Mon Sep 17 00:00:00 2001 From: q0w <43147888+q0w@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:55:35 +0300 Subject: [PATCH] 5.1: Deprecate CheckConstraint.check (#2331) Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- django-stubs/db/models/constraints.pyi | 13 +++++++++++++ tests/assert_type/db/models/test_constraints.py | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/django-stubs/db/models/constraints.pyi b/django-stubs/db/models/constraints.pyi index 7b96ada72..988f0f4b0 100644 --- a/django-stubs/db/models/constraints.pyi +++ b/django-stubs/db/models/constraints.pyi @@ -44,11 +44,24 @@ class BaseConstraint: class CheckConstraint(BaseConstraint): check: Q | BaseExpression + condition: Q | BaseExpression + + @overload + @deprecated("The check keyword argument is deprecated in favor of condition and will be removed in Django 6.0") def __init__( self, *, + name: str, check: Q | BaseExpression, + violation_error_code: str | None = None, + violation_error_message: _StrOrPromise | None = None, + ) -> None: ... + @overload + def __init__( + self, + *, name: str, + condition: Q | BaseExpression, violation_error_code: str | None = None, violation_error_message: _StrOrPromise | None = None, ) -> None: ... diff --git a/tests/assert_type/db/models/test_constraints.py b/tests/assert_type/db/models/test_constraints.py index db0fce1a7..971675559 100644 --- a/tests/assert_type/db/models/test_constraints.py +++ b/tests/assert_type/db/models/test_constraints.py @@ -13,4 +13,4 @@ name="unique_mess", ) -CheckConstraint(name="less_than_constraint", check=LessThan[Any](F("months"), 1)) +CheckConstraint(name="less_than_constraint", check=LessThan[Any](F("months"), 1)) # pyright: ignore[reportDeprecated]