Skip to content

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

Fix types

Rafał Pitoń2aa9493cdaf3
diff --git a/saleor/graphql/attribute/types.py b/saleor/graphql/attribute/types.py
index 397e579b45..ac1e0adb56 100644
--- a/saleor/graphql/attribute/types.py
+++ b/saleor/graphql/attribute/types.py
@@ -1,6 +1,8 @@
import re
+from typing import cast
import graphene
+from django.db.models import Manager
from ...attribute import AttributeInputType, AttributeType, models
from ...core.exceptions import PermissionDenied
@@ -186,7 +188,7 @@ class Attribute(CountableDjangoObjectType):
if root.input_type in AttributeInputType.TYPES_WITH_CHOICES:
qs = root.values.all()
else:
- qs = models.AttributeValue.objects.none()
+ qs = cast(Manager[AttributeValue], models.AttributeValue.objects.none())
qs = filter_connection_queryset(qs, kwargs)
return create_connection_slice(
diff --git a/saleor/graphql/core/connection.py b/saleor/graphql/core/connection.py
index 065e130235..759a052c3e 100644
--- a/saleor/graphql/core/connection.py
+++ b/saleor/graphql/core/connection.py
@@ -1,6 +1,6 @@
import json
from decimal import Decimal, InvalidOperation
-from typing import Any, Dict, Iterable, List, Optional, Tuple, Union
+from typing import Any, Dict, Iterable, List, Optional, Tuple, Union, cast
import graphene
from django.conf import settings
@@ -348,7 +348,7 @@ def _validate_slice_args(
)
if max_limit is None:
- max_limit = settings.GRAPHENE.get("RELAY_CONNECTION_MAX_LIMIT", 0)
+ max_limit = cast(int, settings.GRAPHENE.get("RELAY_CONNECTION_MAX_LIMIT", 0))
if max_limit:
if first:
diff --git a/saleor/graphql/core/fields.py b/saleor/graphql/core/fields.py
index 0ab645700a..9811e8ae06 100644
--- a/saleor/graphql/core/fields.py
+++ b/saleor/graphql/core/fields.py
@@ -45,7 +45,8 @@ class ConnectionField(graphene.Field):
if is_node(connection_type):
raise Exception(
"ConnectionFields now need a explicit ConnectionType for Nodes.\n"
- "Read more: https://github.com/graphql-python/graphene/blob/v2.0.0/UPGRADE-v2.0.md#node-connections"
+ "Read more: https://github.com/graphql-python/graphene/blob/v2.0.0/"
+ "UPGRADE-v2.0.md#node-connections"
)
assert issubclass(connection_type, Connection), (
diff --git a/saleor/graphql/warehouse/types.py b/saleor/graphql/warehouse/types.py
index cb4214866a..61e2942a97 100644
--- a/saleor/graphql/warehouse/types.py
+++ b/saleor/graphql/warehouse/types.py
@@ -45,9 +45,7 @@ class WarehouseUpdateInput(WarehouseInput):
required=False,
)
click_and_collect_option = WarehouseClickAndCollectOptionEnum(
- description=(
- f"{ADDED_IN_31} Click and collect options: local, all or disabled"
- ),
+ description=f"{ADDED_IN_31} Click and collect options: local, all or disabled",
required=False,
)
is_private = graphene.Boolean(