Skip to content

Commit

Permalink
Migrate db/models/test_constraints.yml to 'assert_type' tests (#2204)
Browse files Browse the repository at this point in the history
  • Loading branch information
flaeppe authored Jun 5, 2024
1 parent ea0dd4a commit 01618e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 47 deletions.
16 changes: 16 additions & 0 deletions tests/assert_type/db/models/test_constraints.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from typing import Any

from django.db.models import CheckConstraint, F, UniqueConstraint
from django.db.models.functions import Lower
from django.db.models.lookups import LessThan

UniqueConstraint(Lower("name").desc(), "category", name="unique_lower_name_category")
UniqueConstraint(fields=["name"], name="unqiue_name")
# There's no overload case for passing both expression and 'fields'
UniqueConstraint( # type: ignore[call-overload]
Lower("name"),
fields=["name"], # pyright: ignore[reportArgumentType]
name="unique_mess",
)

CheckConstraint(name="less_than_constraint", check=LessThan[Any](F("months"), 1))
47 changes: 0 additions & 47 deletions tests/typecheck/db/models/test_constraints.yml

This file was deleted.

0 comments on commit 01618e4

Please sign in to comment.