From d601f6ed9e701d296b1f89d2478d4a52da58857d Mon Sep 17 00:00:00 2001 From: q0w <43147888+q0w@users.noreply.github.com> Date: Fri, 9 Aug 2024 11:14:21 +0300 Subject: [PATCH 1/6] 5.1: Deprecate CheckConstraint.check --- django-stubs/db/models/constraints.pyi | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/django-stubs/db/models/constraints.pyi b/django-stubs/db/models/constraints.pyi index 7b96ada72..2aacbd4ed 100644 --- a/django-stubs/db/models/constraints.pyi +++ b/django-stubs/db/models/constraints.pyi @@ -44,11 +44,23 @@ class BaseConstraint: class CheckConstraint(BaseConstraint): check: Q | BaseExpression + + @overload 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: ... From 4c96c386076280e6d93e53e5965d964eeff72374 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 9 Aug 2024 08:20:22 +0000 Subject: [PATCH 2/6] [pre-commit.ci] auto fixes from pre-commit.com hooks --- django-stubs/db/models/constraints.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/django-stubs/db/models/constraints.pyi b/django-stubs/db/models/constraints.pyi index 2aacbd4ed..674a61878 100644 --- a/django-stubs/db/models/constraints.pyi +++ b/django-stubs/db/models/constraints.pyi @@ -54,7 +54,6 @@ class CheckConstraint(BaseConstraint): violation_error_code: str | None = None, violation_error_message: _StrOrPromise | None = None, ) -> None: ... - @overload def __init__( self, From 47a658a2f93adc21f00418e7107cf59f0bad59af Mon Sep 17 00:00:00 2001 From: q0w <43147888+q0w@users.noreply.github.com> Date: Sat, 10 Aug 2024 16:59:26 +0300 Subject: [PATCH 3/6] Deprecate check --- django-stubs/db/models/constraints.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/django-stubs/db/models/constraints.pyi b/django-stubs/db/models/constraints.pyi index 674a61878..af95a3cc8 100644 --- a/django-stubs/db/models/constraints.pyi +++ b/django-stubs/db/models/constraints.pyi @@ -45,6 +45,7 @@ class BaseConstraint: class CheckConstraint(BaseConstraint): check: Q | BaseExpression + @deprecated("The check keyword argument is deprecated in favor of condition and will be removed in Django 6.0") @overload def __init__( self, From 109b36ad955fc6aa3b37a66fa247b509e2056e50 Mon Sep 17 00:00:00 2001 From: q0w <43147888+q0w@users.noreply.github.com> Date: Sat, 10 Aug 2024 17:03:01 +0300 Subject: [PATCH 4/6] Add condition attr --- django-stubs/db/models/constraints.pyi | 1 + 1 file changed, 1 insertion(+) diff --git a/django-stubs/db/models/constraints.pyi b/django-stubs/db/models/constraints.pyi index af95a3cc8..e9e1ce59a 100644 --- a/django-stubs/db/models/constraints.pyi +++ b/django-stubs/db/models/constraints.pyi @@ -44,6 +44,7 @@ class BaseConstraint: class CheckConstraint(BaseConstraint): check: Q | BaseExpression + condition: Q | BaseExpression @deprecated("The check keyword argument is deprecated in favor of condition and will be removed in Django 6.0") @overload From 50d1db693397d0d7e43e88cfcce0537991578480 Mon Sep 17 00:00:00 2001 From: q0w <43147888+q0w@users.noreply.github.com> Date: Thu, 22 Aug 2024 10:49:31 +0300 Subject: [PATCH 5/6] Fixup order --- django-stubs/db/models/constraints.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django-stubs/db/models/constraints.pyi b/django-stubs/db/models/constraints.pyi index e9e1ce59a..988f0f4b0 100644 --- a/django-stubs/db/models/constraints.pyi +++ b/django-stubs/db/models/constraints.pyi @@ -46,8 +46,8 @@ class CheckConstraint(BaseConstraint): check: Q | BaseExpression condition: Q | BaseExpression - @deprecated("The check keyword argument is deprecated in favor of condition and will be removed in Django 6.0") @overload + @deprecated("The check keyword argument is deprecated in favor of condition and will be removed in Django 6.0") def __init__( self, *, From 0e2f6512ecc8cc5dae1a20f92c4d1e8a49aea8b7 Mon Sep 17 00:00:00 2001 From: q0w <43147888+q0w@users.noreply.github.com> Date: Thu, 22 Aug 2024 14:40:25 +0300 Subject: [PATCH 6/6] pyright: Ignore reportDeprecated --- tests/assert_type/db/models/test_constraints.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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]