summaryrefslogtreecommitdiff
path: root/django/contrib/postgres/constraints.py
diff options
context:
space:
mode:
authorNick Pope <nick@nickpope.me.uk>2023-01-18 16:27:23 +0000
committerGitHub <noreply@github.com>2023-01-18 17:27:23 +0100
commitfd21f82aa82b0d75a161f618ef944ebe0923e0ab (patch)
tree7ca34bc34988e10427c99c7772b88238d28afd9f /django/contrib/postgres/constraints.py
parent26a395f27d86bbf65f330851c8136c33694ac867 (diff)
downloaddjango-fd21f82aa82b0d75a161f618ef944ebe0923e0ab.tar.gz
Refs #34233 -- Used types.NoneType.
Available since Python 3.10 where it was reintroduced.
Diffstat (limited to 'django/contrib/postgres/constraints.py')
-rw-r--r--django/contrib/postgres/constraints.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/django/contrib/postgres/constraints.py b/django/contrib/postgres/constraints.py
index 4c739b3fbb..30ef7602a5 100644
--- a/django/contrib/postgres/constraints.py
+++ b/django/contrib/postgres/constraints.py
@@ -1,3 +1,5 @@
+from types import NoneType
+
from django.contrib.postgres.indexes import OpClass
from django.core.exceptions import ValidationError
from django.db import DEFAULT_DB_ALIAS, NotSupportedError
@@ -45,13 +47,13 @@ class ExclusionConstraint(BaseConstraint):
isinstance(expr, (list, tuple)) and len(expr) == 2 for expr in expressions
):
raise ValueError("The expressions must be a list of 2-tuples.")
- if not isinstance(condition, (type(None), Q)):
+ if not isinstance(condition, (NoneType, Q)):
raise ValueError("ExclusionConstraint.condition must be a Q instance.")
- if not isinstance(deferrable, (type(None), Deferrable)):
+ if not isinstance(deferrable, (NoneType, Deferrable)):
raise ValueError(
"ExclusionConstraint.deferrable must be a Deferrable instance."
)
- if not isinstance(include, (type(None), list, tuple)):
+ if not isinstance(include, (NoneType, list, tuple)):
raise ValueError("ExclusionConstraint.include must be a list or tuple.")
self.expressions = expressions
self.index_type = index_type or "GIST"