Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Ignore mypy in JSONField imports

Marcin Gębala43262efc09bb
diff --git a/saleor/account/models.py b/saleor/account/models.py
index eac5ef76b0..e46fb23480 100644
--- a/saleor/account/models.py
+++ b/saleor/account/models.py
@@ -9,6 +9,7 @@ from django.contrib.auth.models import (
PermissionsMixin,
)
from django.db import models
+from django.db.models import JSONField # type: ignore
from django.db.models import Q, QuerySet, Value
from django.forms.models import model_to_dict
from django.utils import timezone
@@ -232,7 +233,7 @@ class CustomerEvent(models.Model):
],
)
order = models.ForeignKey("order.Order", on_delete=models.SET_NULL, null=True)
- parameters = models.JSONField(blank=True, default=dict, encoder=CustomJsonEncoder)
+ parameters = JSONField(blank=True, default=dict, encoder=CustomJsonEncoder)
user = models.ForeignKey(User, related_name="events", on_delete=models.CASCADE)
class Meta:
diff --git a/saleor/checkout/models.py b/saleor/checkout/models.py
index 73a2e8cba7..6bd845be77 100644
--- a/saleor/checkout/models.py
+++ b/saleor/checkout/models.py
@@ -6,6 +6,7 @@ from uuid import uuid4
from django.conf import settings
from django.core.validators import MinValueValidator
from django.db import models
+from django.db.models import JSONField # type: ignore
from django.utils.encoding import smart_str
from django_countries.fields import Country, CountryField
from django_prices.models import MoneyField
@@ -177,7 +178,7 @@ class CheckoutLine(models.Model):
"product.ProductVariant", related_name="+", on_delete=models.CASCADE
)
quantity = models.PositiveIntegerField(validators=[MinValueValidator(1)])
- data = models.JSONField(blank=True, default=dict)
+ data = JSONField(blank=True, default=dict)
class Meta:
unique_together = ("checkout", "variant", "data")
diff --git a/saleor/core/db/fields.py b/saleor/core/db/fields.py
index d6b6b9e113..81447aeea7 100644
--- a/saleor/core/db/fields.py
+++ b/saleor/core/db/fields.py
@@ -1,7 +1,7 @@
import json
from typing import Callable
-from django.db.models import JSONField
+from django.db.models import JSONField # type: ignore
class SanitizedJSONField(JSONField):
diff --git a/saleor/core/models.py b/saleor/core/models.py
index 334ec1944b..1de36ccd6a 100644
--- a/saleor/core/models.py
+++ b/saleor/core/models.py
@@ -2,6 +2,7 @@ import datetime
from typing import Any
from django.db import models
+from django.db.models import JSONField # type: ignore
from django.db.models import F, Max, Q
from . import JobStatus
@@ -75,12 +76,10 @@ class PublishableModel(models.Model):
class ModelWithMetadata(models.Model):
- private_metadata = models.JSONField(
- blank=True, null=True, default=dict, encoder=CustomJsonEncoder
- )
- metadata = models.JSONField(
+ private_metadata = JSONField(
blank=True, null=True, default=dict, encoder=CustomJsonEncoder
)
+ metadata = JSONField(blank=True, null=True, default=dict, encoder=CustomJsonEncoder)
class Meta:
abstract = True
diff --git a/saleor/csv/models.py b/saleor/csv/models.py
index 5344ef2603..56d13a8c48 100644
--- a/saleor/csv/models.py
+++ b/saleor/csv/models.py
@@ -1,4 +1,5 @@
from django.db import models
+from django.db.models import JSONField # type: ignore
from django.utils import timezone
from ..account.models import User
@@ -23,7 +24,7 @@ class ExportEvent(models.Model):
date = models.DateTimeField(default=timezone.now, editable=False)
type = models.CharField(max_length=255, choices=ExportEvents.CHOICES)
- parameters = models.JSONField(blank=True, default=dict, encoder=CustomJsonEncoder)
+ parameters = JSONField(blank=True, default=dict, encoder=CustomJsonEncoder)
export_file = models.ForeignKey(
ExportFile, related_name="events", on_delete=models.CASCADE
)
diff --git a/saleor/graphql/core/types/converter.py b/saleor/graphql/core/types/converter.py
index 3480f92652..84f867fa44 100644
--- a/saleor/graphql/core/types/converter.py
+++ b/saleor/graphql/core/types/converter.py
@@ -1,5 +1,5 @@
import graphene
-from django.db.models import JSONField
+from django.db.models import JSONField # type: ignore
from django_measurement.models import MeasurementField
from django_prices.models import MoneyField, TaxedMoneyField
from graphene.types.json import JSONString
diff --git a/saleor/invoice/models.py b/saleor/invoice/models.py
index a51503aacd..d8bd1c2e8a 100644
--- a/saleor/invoice/models.py
+++ b/saleor/invoice/models.py
@@ -1,5 +1,6 @@
from django.conf import settings
from django.db import models
+from django.db.models import JSONField # type: ignore
from django.utils.timezone import now
from ..core import JobStatus
@@ -63,7 +64,7 @@ class InvoiceEvent(models.Model):
on_delete=models.SET_NULL,
related_name="+",
)
- parameters = models.JSONField(blank=True, default=dict, encoder=CustomJsonEncoder)
+ parameters = JSONField(blank=True, default=dict, encoder=CustomJsonEncoder)
class Meta:
ordering = ("date", "pk")
diff --git a/saleor/order/models.py b/saleor/order/models.py
index ce3681c0ce..69cbd319ba 100644
--- a/saleor/order/models.py
+++ b/saleor/order/models.py
@@ -7,6 +7,7 @@ from uuid import uuid4
from django.conf import settings
from django.core.validators import MinValueValidator
from django.db import models
+from django.db.models import JSONField # type: ignore
from django.db.models import F, Max, Sum
from django.utils.timezone import now
from django_measurement.models import MeasurementField
@@ -506,7 +507,7 @@ class OrderEvent(models.Model):
],
)
order = models.ForeignKey(Order, related_name="events", on_delete=models.CASCADE)
- parameters = models.JSONField(blank=True, default=dict, encoder=CustomJsonEncoder)
+ parameters = JSONField(blank=True, default=dict, encoder=CustomJsonEncoder)
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
blank=True,
diff --git a/saleor/payment/models.py b/saleor/payment/models.py
index a0fc9238f5..93688f6816 100644
--- a/saleor/payment/models.py
+++ b/saleor/payment/models.py
@@ -5,6 +5,7 @@ from django.conf import settings
from django.core.serializers.json import DjangoJSONEncoder
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
+from django.db.models import JSONField # type: ignore
from prices import Money
from ..checkout.models import Checkout
@@ -208,7 +209,7 @@ class Transaction(models.Model):
null=True,
)
customer_id = models.CharField(max_length=256, null=True)
- gateway_response = models.JSONField(encoder=DjangoJSONEncoder)
+ gateway_response = JSONField(encoder=DjangoJSONEncoder)
class Meta:
ordering = ("pk",)
diff --git a/saleor/plugins/models.py b/saleor/plugins/models.py
index e1d30ae2ce..6fca708e26 100644
--- a/saleor/plugins/models.py
+++ b/saleor/plugins/models.py
@@ -1,4 +1,5 @@
from django.db import models
+from django.db.models import JSONField # type: ignore
from ..core.permissions import PluginsPermissions
from ..core.utils.json_serializer import CustomJsonEncoder
@@ -9,7 +10,7 @@ class PluginConfiguration(models.Model):
name = models.CharField(max_length=128)
description = models.TextField(blank=True)
active = models.BooleanField(default=True)
- configuration = models.JSONField(
+ configuration = JSONField(
blank=True, null=True, default=dict, encoder=CustomJsonEncoder
)
diff --git a/saleor/product/models.py b/saleor/product/models.py
index bdeabdc79b..9604624dc8 100644
--- a/saleor/product/models.py
+++ b/saleor/product/models.py
@@ -4,6 +4,7 @@ from uuid import uuid4
from django.conf import settings
from django.contrib.postgres.aggregates import StringAgg
from django.db import models
+from django.db.models import JSONField # type: ignore
from django.db.models import Case, Count, F, FilteredRelation, Q, Value, When
from django.urls import reverse
from django.utils.encoding import smart_text
@@ -44,7 +45,7 @@ class Category(MPTTModel, ModelWithMetadata, SeoModel):
name = models.CharField(max_length=250)
slug = models.SlugField(max_length=255, unique=True, allow_unicode=True)
description = models.TextField(blank=True)
- description_json = models.JSONField(blank=True, default=dict)
+ description_json = JSONField(blank=True, default=dict)
parent = models.ForeignKey(
"self", null=True, blank=True, related_name="children", on_delete=models.CASCADE
)
@@ -68,7 +69,7 @@ class CategoryTranslation(SeoModelTranslation):
)
name = models.CharField(max_length=128)
description = models.TextField(blank=True)
- description_json = models.JSONField(blank=True, default=dict)
+ description_json = JSONField(blank=True, default=dict)
class Meta:
unique_together = (("language_code", "category"),)
@@ -835,7 +836,7 @@ class Collection(SeoModel, ModelWithMetadata, PublishableModel):
)
background_image_alt = models.CharField(max_length=128, blank=True)
description = models.TextField(blank=True)
- description_json = models.JSONField(blank=True, default=dict)
+ description_json = JSONField(blank=True, default=dict)
translated = TranslationProxy()
@@ -853,7 +854,7 @@ class CollectionTranslation(SeoModelTranslation):
)
name = models.CharField(max_length=128)
description = models.TextField(blank=True)
- description_json = models.JSONField(blank=True, default=dict)
+ description_json = JSONField(blank=True, default=dict)
class Meta:
unique_together = (("language_code", "collection"),)