Skip to content

Commit

Permalink
5.1: Deprecate CheckConstraint.check (#2331)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
q0w and pre-commit-ci[bot] committed Aug 22, 2024
1 parent 807090a commit ead941f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions django-stubs/db/models/constraints.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
2 changes: 1 addition & 1 deletion tests/assert_type/db/models/test_constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

0 comments on commit ead941f

Please sign in to comment.