strawberry-graphql 0.283.0__py3-none-any.whl → 0.284.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of strawberry-graphql might be problematic. Click here for more details.
- strawberry/aiohttp/test/client.py +8 -15
- strawberry/aiohttp/views.py +12 -15
- strawberry/annotation.py +19 -23
- strawberry/asgi/__init__.py +18 -17
- strawberry/asgi/test/client.py +6 -6
- strawberry/chalice/views.py +6 -6
- strawberry/channels/handlers/base.py +7 -8
- strawberry/channels/handlers/http_handler.py +18 -20
- strawberry/channels/handlers/ws_handler.py +10 -12
- strawberry/channels/router.py +3 -4
- strawberry/channels/testing.py +7 -9
- strawberry/cli/commands/codegen.py +7 -7
- strawberry/cli/commands/schema_codegen.py +1 -2
- strawberry/cli/commands/upgrade/__init__.py +1 -3
- strawberry/cli/commands/upgrade/_run_codemod.py +2 -2
- strawberry/codegen/plugins/print_operation.py +2 -2
- strawberry/codegen/plugins/python.py +2 -2
- strawberry/codegen/query_codegen.py +20 -30
- strawberry/codegen/types.py +32 -32
- strawberry/codemods/annotated_unions.py +2 -2
- strawberry/dataloader.py +28 -24
- strawberry/directive.py +6 -7
- strawberry/django/test/client.py +3 -3
- strawberry/django/views.py +16 -19
- strawberry/exceptions/__init__.py +4 -4
- strawberry/exceptions/conflicting_arguments.py +2 -2
- strawberry/exceptions/duplicated_type_name.py +4 -4
- strawberry/exceptions/exception.py +3 -3
- strawberry/exceptions/handler.py +8 -7
- strawberry/exceptions/invalid_argument_type.py +2 -2
- strawberry/exceptions/invalid_superclass_interface.py +2 -2
- strawberry/exceptions/invalid_union_type.py +4 -4
- strawberry/exceptions/missing_arguments_annotations.py +2 -2
- strawberry/exceptions/missing_dependencies.py +2 -4
- strawberry/exceptions/missing_field_annotation.py +2 -2
- strawberry/exceptions/missing_return_annotation.py +2 -2
- strawberry/exceptions/object_is_not_a_class.py +2 -2
- strawberry/exceptions/object_is_not_an_enum.py +2 -2
- strawberry/exceptions/permission_fail_silently_requires_optional.py +2 -2
- strawberry/exceptions/private_strawberry_field.py +2 -2
- strawberry/exceptions/scalar_already_registered.py +2 -2
- strawberry/exceptions/syntax.py +3 -3
- strawberry/exceptions/unresolved_field_type.py +2 -2
- strawberry/exceptions/utils/source_finder.py +25 -25
- strawberry/experimental/pydantic/_compat.py +8 -7
- strawberry/experimental/pydantic/conversion.py +2 -2
- strawberry/experimental/pydantic/conversion_types.py +2 -2
- strawberry/experimental/pydantic/error_type.py +10 -12
- strawberry/experimental/pydantic/fields.py +9 -15
- strawberry/experimental/pydantic/object_type.py +15 -23
- strawberry/experimental/pydantic/utils.py +1 -2
- strawberry/ext/mypy_plugin.py +12 -14
- strawberry/extensions/base_extension.py +2 -1
- strawberry/extensions/context.py +13 -18
- strawberry/extensions/directives.py +3 -1
- strawberry/extensions/field_extension.py +4 -4
- strawberry/extensions/max_aliases.py +1 -3
- strawberry/extensions/parser_cache.py +1 -2
- strawberry/extensions/query_depth_limiter.py +18 -14
- strawberry/extensions/runner.py +2 -2
- strawberry/extensions/tracing/apollo.py +3 -3
- strawberry/extensions/tracing/datadog.py +3 -3
- strawberry/extensions/tracing/opentelemetry.py +6 -8
- strawberry/extensions/tracing/utils.py +3 -1
- strawberry/extensions/utils.py +2 -2
- strawberry/extensions/validation_cache.py +1 -2
- strawberry/fastapi/context.py +6 -6
- strawberry/fastapi/router.py +33 -36
- strawberry/federation/argument.py +4 -5
- strawberry/federation/enum.py +18 -21
- strawberry/federation/field.py +94 -97
- strawberry/federation/object_type.py +56 -58
- strawberry/federation/scalar.py +27 -35
- strawberry/federation/schema.py +15 -16
- strawberry/federation/schema_directive.py +7 -6
- strawberry/federation/schema_directives.py +11 -11
- strawberry/federation/union.py +4 -4
- strawberry/flask/views.py +10 -11
- strawberry/http/__init__.py +14 -14
- strawberry/http/async_base_view.py +23 -28
- strawberry/http/base.py +11 -12
- strawberry/http/ides.py +2 -3
- strawberry/http/sync_base_view.py +11 -13
- strawberry/http/types.py +3 -3
- strawberry/litestar/controller.py +40 -35
- strawberry/permission.py +4 -6
- strawberry/printer/ast_from_value.py +3 -5
- strawberry/printer/printer.py +8 -13
- strawberry/quart/views.py +12 -14
- strawberry/relay/exceptions.py +4 -4
- strawberry/relay/fields.py +33 -32
- strawberry/relay/types.py +31 -34
- strawberry/relay/utils.py +2 -2
- strawberry/resolvers.py +2 -1
- strawberry/sanic/context.py +1 -0
- strawberry/sanic/utils.py +3 -3
- strawberry/sanic/views.py +11 -14
- strawberry/scalars.py +2 -2
- strawberry/schema/_graphql_core.py +5 -5
- strawberry/schema/base.py +32 -33
- strawberry/schema/compat.py +9 -9
- strawberry/schema/config.py +5 -2
- strawberry/schema/exceptions.py +1 -3
- strawberry/schema/name_converter.py +6 -6
- strawberry/schema/schema.py +55 -60
- strawberry/schema/schema_converter.py +27 -22
- strawberry/schema/types/base_scalars.py +1 -1
- strawberry/schema/types/concrete_type.py +5 -5
- strawberry/schema_codegen/__init__.py +3 -3
- strawberry/schema_directive.py +7 -6
- strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py +5 -6
- strawberry/subscriptions/protocols/graphql_transport_ws/types.py +20 -20
- strawberry/subscriptions/protocols/graphql_ws/handlers.py +5 -6
- strawberry/subscriptions/protocols/graphql_ws/types.py +14 -14
- strawberry/test/client.py +18 -18
- strawberry/tools/create_type.py +2 -3
- strawberry/types/arguments.py +25 -26
- strawberry/types/auto.py +3 -4
- strawberry/types/base.py +25 -27
- strawberry/types/enum.py +22 -25
- strawberry/types/execution.py +14 -15
- strawberry/types/field.py +108 -108
- strawberry/types/fields/resolver.py +19 -21
- strawberry/types/info.py +5 -11
- strawberry/types/lazy_type.py +2 -3
- strawberry/types/maybe.py +12 -3
- strawberry/types/mutation.py +115 -118
- strawberry/types/nodes.py +2 -2
- strawberry/types/object_type.py +43 -63
- strawberry/types/scalar.py +37 -43
- strawberry/types/union.py +12 -14
- strawberry/utils/aio.py +12 -9
- strawberry/utils/await_maybe.py +3 -3
- strawberry/utils/deprecations.py +2 -2
- strawberry/utils/importer.py +1 -2
- strawberry/utils/inspect.py +4 -6
- strawberry/utils/logging.py +2 -2
- strawberry/utils/operation.py +4 -4
- strawberry/utils/typing.py +18 -83
- {strawberry_graphql-0.283.0.dist-info → strawberry_graphql-0.284.3.dist-info}/METADATA +2 -2
- strawberry_graphql-0.284.3.dist-info/RECORD +243 -0
- strawberry/utils/dataclasses.py +0 -37
- strawberry_graphql-0.283.0.dist-info/RECORD +0 -244
- {strawberry_graphql-0.283.0.dist-info → strawberry_graphql-0.284.3.dist-info}/WHEEL +0 -0
- {strawberry_graphql-0.283.0.dist-info → strawberry_graphql-0.284.3.dist-info}/entry_points.txt +0 -0
- {strawberry_graphql-0.283.0.dist-info → strawberry_graphql-0.284.3.dist-info}/licenses/LICENSE +0 -0
strawberry/dataloader.py
CHANGED
|
@@ -8,11 +8,8 @@ from dataclasses import dataclass
|
|
|
8
8
|
from typing import (
|
|
9
9
|
TYPE_CHECKING,
|
|
10
10
|
Any,
|
|
11
|
-
Callable,
|
|
12
11
|
Generic,
|
|
13
|
-
Optional,
|
|
14
12
|
TypeVar,
|
|
15
|
-
Union,
|
|
16
13
|
overload,
|
|
17
14
|
)
|
|
18
15
|
|
|
@@ -20,7 +17,14 @@ from .exceptions import WrongNumberOfResultsReturned
|
|
|
20
17
|
|
|
21
18
|
if TYPE_CHECKING:
|
|
22
19
|
from asyncio.events import AbstractEventLoop
|
|
23
|
-
from collections.abc import
|
|
20
|
+
from collections.abc import (
|
|
21
|
+
Awaitable,
|
|
22
|
+
Callable,
|
|
23
|
+
Hashable,
|
|
24
|
+
Iterable,
|
|
25
|
+
Mapping,
|
|
26
|
+
Sequence,
|
|
27
|
+
)
|
|
24
28
|
|
|
25
29
|
|
|
26
30
|
T = TypeVar("T")
|
|
@@ -46,9 +50,9 @@ class Batch(Generic[K, T]):
|
|
|
46
50
|
return len(self.tasks)
|
|
47
51
|
|
|
48
52
|
|
|
49
|
-
class AbstractCache(Generic[K, T]
|
|
53
|
+
class AbstractCache(ABC, Generic[K, T]):
|
|
50
54
|
@abstractmethod
|
|
51
|
-
def get(self, key: K) ->
|
|
55
|
+
def get(self, key: K) -> Future[T] | None:
|
|
52
56
|
pass
|
|
53
57
|
|
|
54
58
|
@abstractmethod
|
|
@@ -65,13 +69,13 @@ class AbstractCache(Generic[K, T], ABC):
|
|
|
65
69
|
|
|
66
70
|
|
|
67
71
|
class DefaultCache(AbstractCache[K, T]):
|
|
68
|
-
def __init__(self, cache_key_fn:
|
|
72
|
+
def __init__(self, cache_key_fn: Callable[[K], Hashable] | None = None) -> None:
|
|
69
73
|
self.cache_key_fn: Callable[[K], Hashable] = (
|
|
70
74
|
cache_key_fn if cache_key_fn is not None else lambda x: x
|
|
71
75
|
)
|
|
72
76
|
self.cache_map: dict[Hashable, Future[T]] = {}
|
|
73
77
|
|
|
74
|
-
def get(self, key: K) ->
|
|
78
|
+
def get(self, key: K) -> Future[T] | None:
|
|
75
79
|
return self.cache_map.get(self.cache_key_fn(key))
|
|
76
80
|
|
|
77
81
|
def set(self, key: K, value: Future[T]) -> None:
|
|
@@ -85,7 +89,7 @@ class DefaultCache(AbstractCache[K, T]):
|
|
|
85
89
|
|
|
86
90
|
|
|
87
91
|
class DataLoader(Generic[K, T]):
|
|
88
|
-
batch:
|
|
92
|
+
batch: Batch[K, T] | None = None
|
|
89
93
|
cache: bool = False
|
|
90
94
|
cache_map: AbstractCache[K, T]
|
|
91
95
|
|
|
@@ -93,12 +97,12 @@ class DataLoader(Generic[K, T]):
|
|
|
93
97
|
def __init__(
|
|
94
98
|
self,
|
|
95
99
|
# any BaseException is rethrown in 'load', so should be excluded from the T type
|
|
96
|
-
load_fn: Callable[[list[K]], Awaitable[Sequence[
|
|
97
|
-
max_batch_size:
|
|
100
|
+
load_fn: Callable[[list[K]], Awaitable[Sequence[T | BaseException]]],
|
|
101
|
+
max_batch_size: int | None = None,
|
|
98
102
|
cache: bool = True,
|
|
99
|
-
loop:
|
|
100
|
-
cache_map:
|
|
101
|
-
cache_key_fn:
|
|
103
|
+
loop: AbstractEventLoop | None = None,
|
|
104
|
+
cache_map: AbstractCache[K, T] | None = None,
|
|
105
|
+
cache_key_fn: Callable[[K], Hashable] | None = None,
|
|
102
106
|
) -> None: ...
|
|
103
107
|
|
|
104
108
|
# fallback if load_fn is untyped and there's no other info for inference
|
|
@@ -106,21 +110,21 @@ class DataLoader(Generic[K, T]):
|
|
|
106
110
|
def __init__(
|
|
107
111
|
self: DataLoader[K, Any],
|
|
108
112
|
load_fn: Callable[[list[K]], Awaitable[list[Any]]],
|
|
109
|
-
max_batch_size:
|
|
113
|
+
max_batch_size: int | None = None,
|
|
110
114
|
cache: bool = True,
|
|
111
|
-
loop:
|
|
112
|
-
cache_map:
|
|
113
|
-
cache_key_fn:
|
|
115
|
+
loop: AbstractEventLoop | None = None,
|
|
116
|
+
cache_map: AbstractCache[K, T] | None = None,
|
|
117
|
+
cache_key_fn: Callable[[K], Hashable] | None = None,
|
|
114
118
|
) -> None: ...
|
|
115
119
|
|
|
116
120
|
def __init__(
|
|
117
121
|
self,
|
|
118
|
-
load_fn: Callable[[list[K]], Awaitable[Sequence[
|
|
119
|
-
max_batch_size:
|
|
122
|
+
load_fn: Callable[[list[K]], Awaitable[Sequence[T | BaseException]]],
|
|
123
|
+
max_batch_size: int | None = None,
|
|
120
124
|
cache: bool = True,
|
|
121
|
-
loop:
|
|
122
|
-
cache_map:
|
|
123
|
-
cache_key_fn:
|
|
125
|
+
loop: AbstractEventLoop | None = None,
|
|
126
|
+
cache_map: AbstractCache[K, T] | None = None,
|
|
127
|
+
cache_key_fn: Callable[[K], Hashable] | None = None,
|
|
124
128
|
):
|
|
125
129
|
self.load_fn = load_fn
|
|
126
130
|
self.max_batch_size = max_batch_size
|
|
@@ -244,7 +248,7 @@ async def dispatch_batch(loader: DataLoader, batch: Batch) -> None:
|
|
|
244
248
|
expected=len(batch), received=len(values)
|
|
245
249
|
)
|
|
246
250
|
|
|
247
|
-
for task, value in zip(batch.tasks, values):
|
|
251
|
+
for task, value in zip(batch.tasks, values, strict=True):
|
|
248
252
|
# Trying to set_result in a cancelled future would raise
|
|
249
253
|
# asyncio.exceptions.InvalidStateError
|
|
250
254
|
if task.future.cancelled():
|
strawberry/directive.py
CHANGED
|
@@ -6,9 +6,7 @@ from typing import (
|
|
|
6
6
|
TYPE_CHECKING,
|
|
7
7
|
Annotated,
|
|
8
8
|
Any,
|
|
9
|
-
Callable,
|
|
10
9
|
Generic,
|
|
11
|
-
Optional,
|
|
12
10
|
TypeVar,
|
|
13
11
|
)
|
|
14
12
|
|
|
@@ -24,6 +22,7 @@ from strawberry.types.unset import UNSET
|
|
|
24
22
|
|
|
25
23
|
if TYPE_CHECKING:
|
|
26
24
|
import inspect
|
|
25
|
+
from collections.abc import Callable
|
|
27
26
|
|
|
28
27
|
from strawberry.types.arguments import StrawberryArgument
|
|
29
28
|
|
|
@@ -82,17 +81,17 @@ class StrawberryDirectiveResolver(StrawberryResolver[T]):
|
|
|
82
81
|
)
|
|
83
82
|
|
|
84
83
|
@cached_property
|
|
85
|
-
def value_parameter(self) ->
|
|
84
|
+
def value_parameter(self) -> inspect.Parameter | None:
|
|
86
85
|
return self.reserved_parameters.get(VALUE_PARAMSPEC)
|
|
87
86
|
|
|
88
87
|
|
|
89
88
|
@dataclasses.dataclass
|
|
90
89
|
class StrawberryDirective(Generic[T]):
|
|
91
90
|
python_name: str
|
|
92
|
-
graphql_name:
|
|
91
|
+
graphql_name: str | None
|
|
93
92
|
resolver: StrawberryDirectiveResolver[T]
|
|
94
93
|
locations: list[DirectiveLocation]
|
|
95
|
-
description:
|
|
94
|
+
description: str | None = None
|
|
96
95
|
|
|
97
96
|
@cached_property
|
|
98
97
|
def arguments(self) -> list[StrawberryArgument]:
|
|
@@ -102,8 +101,8 @@ class StrawberryDirective(Generic[T]):
|
|
|
102
101
|
def directive(
|
|
103
102
|
*,
|
|
104
103
|
locations: list[DirectiveLocation],
|
|
105
|
-
description:
|
|
106
|
-
name:
|
|
104
|
+
description: str | None = None,
|
|
105
|
+
name: str | None = None,
|
|
107
106
|
) -> Callable[[Callable[..., T]], StrawberryDirective[T]]:
|
|
108
107
|
"""Decorator to create a GraphQL operation directive.
|
|
109
108
|
|
strawberry/django/test/client.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
from typing import Any
|
|
1
|
+
from typing import Any
|
|
2
2
|
|
|
3
3
|
from strawberry.test import BaseGraphQLTestClient
|
|
4
4
|
|
|
@@ -7,8 +7,8 @@ class GraphQLTestClient(BaseGraphQLTestClient):
|
|
|
7
7
|
def request(
|
|
8
8
|
self,
|
|
9
9
|
body: dict[str, object],
|
|
10
|
-
headers:
|
|
11
|
-
files:
|
|
10
|
+
headers: dict[str, object] | None = None,
|
|
11
|
+
files: dict[str, object] | None = None,
|
|
12
12
|
) -> Any:
|
|
13
13
|
if files:
|
|
14
14
|
return self._client.post(
|
strawberry/django/views.py
CHANGED
|
@@ -5,11 +5,8 @@ import warnings
|
|
|
5
5
|
from typing import (
|
|
6
6
|
TYPE_CHECKING,
|
|
7
7
|
Any,
|
|
8
|
-
|
|
9
|
-
Optional,
|
|
10
|
-
Union,
|
|
8
|
+
TypeGuard,
|
|
11
9
|
)
|
|
12
|
-
from typing_extensions import TypeGuard
|
|
13
10
|
|
|
14
11
|
from asgiref.sync import markcoroutinefunction
|
|
15
12
|
from django.core.serializers.json import DjangoJSONEncoder
|
|
@@ -37,7 +34,7 @@ from strawberry.http.typevars import (
|
|
|
37
34
|
from .context import StrawberryDjangoContext
|
|
38
35
|
|
|
39
36
|
if TYPE_CHECKING:
|
|
40
|
-
from collections.abc import AsyncIterator
|
|
37
|
+
from collections.abc import AsyncIterator, Callable
|
|
41
38
|
|
|
42
39
|
from django.template.response import TemplateResponse
|
|
43
40
|
|
|
@@ -48,7 +45,7 @@ if TYPE_CHECKING:
|
|
|
48
45
|
|
|
49
46
|
# TODO: remove this and unify temporal responses
|
|
50
47
|
class TemporalHttpResponse(JsonResponse):
|
|
51
|
-
status_code:
|
|
48
|
+
status_code: int | None = None # pyright: ignore
|
|
52
49
|
|
|
53
50
|
def __init__(self) -> None:
|
|
54
51
|
super().__init__({})
|
|
@@ -71,8 +68,8 @@ class BaseView:
|
|
|
71
68
|
def __init__(
|
|
72
69
|
self,
|
|
73
70
|
schema: BaseSchema,
|
|
74
|
-
graphiql:
|
|
75
|
-
graphql_ide:
|
|
71
|
+
graphiql: str | None = None,
|
|
72
|
+
graphql_ide: GraphQL_IDE | None = "graphiql",
|
|
76
73
|
allow_queries_via_get: bool = True,
|
|
77
74
|
multipart_uploads_enabled: bool = False,
|
|
78
75
|
**kwargs: Any,
|
|
@@ -95,7 +92,7 @@ class BaseView:
|
|
|
95
92
|
|
|
96
93
|
def create_response(
|
|
97
94
|
self,
|
|
98
|
-
response_data:
|
|
95
|
+
response_data: GraphQLHTTPResponse | list[GraphQLHTTPResponse],
|
|
99
96
|
sub_response: HttpResponse,
|
|
100
97
|
) -> HttpResponseBase:
|
|
101
98
|
data = self.encode_json(response_data)
|
|
@@ -143,13 +140,13 @@ class GraphQLView(
|
|
|
143
140
|
],
|
|
144
141
|
View,
|
|
145
142
|
):
|
|
146
|
-
graphiql:
|
|
147
|
-
graphql_ide:
|
|
143
|
+
graphiql: bool | None = None
|
|
144
|
+
graphql_ide: GraphQL_IDE | None = "graphiql"
|
|
148
145
|
allow_queries_via_get = True
|
|
149
146
|
schema: BaseSchema = None # type: ignore
|
|
150
147
|
request_adapter_class = DjangoHTTPRequestAdapter
|
|
151
148
|
|
|
152
|
-
def get_root_value(self, request: HttpRequest) ->
|
|
149
|
+
def get_root_value(self, request: HttpRequest) -> RootValue | None:
|
|
153
150
|
return None
|
|
154
151
|
|
|
155
152
|
def get_context(self, request: HttpRequest, response: HttpResponse) -> Context:
|
|
@@ -160,7 +157,7 @@ class GraphQLView(
|
|
|
160
157
|
|
|
161
158
|
def dispatch(
|
|
162
159
|
self, request: HttpRequest, *args: Any, **kwargs: Any
|
|
163
|
-
) ->
|
|
160
|
+
) -> HttpResponseNotAllowed | TemplateResponse | HttpResponseBase:
|
|
164
161
|
try:
|
|
165
162
|
return self.run(request=request)
|
|
166
163
|
except HTTPException as e:
|
|
@@ -191,8 +188,8 @@ class AsyncGraphQLView(
|
|
|
191
188
|
],
|
|
192
189
|
View,
|
|
193
190
|
):
|
|
194
|
-
graphiql:
|
|
195
|
-
graphql_ide:
|
|
191
|
+
graphiql: bool | None = None
|
|
192
|
+
graphql_ide: GraphQL_IDE | None = "graphiql"
|
|
196
193
|
allow_queries_via_get = True
|
|
197
194
|
schema: BaseSchema = None # type: ignore
|
|
198
195
|
request_adapter_class = AsyncDjangoHTTPRequestAdapter
|
|
@@ -207,7 +204,7 @@ class AsyncGraphQLView(
|
|
|
207
204
|
|
|
208
205
|
return view
|
|
209
206
|
|
|
210
|
-
async def get_root_value(self, request: HttpRequest) ->
|
|
207
|
+
async def get_root_value(self, request: HttpRequest) -> RootValue | None:
|
|
211
208
|
return None
|
|
212
209
|
|
|
213
210
|
async def get_context(
|
|
@@ -220,7 +217,7 @@ class AsyncGraphQLView(
|
|
|
220
217
|
|
|
221
218
|
async def dispatch( # pyright: ignore
|
|
222
219
|
self, request: HttpRequest, *args: Any, **kwargs: Any
|
|
223
|
-
) ->
|
|
220
|
+
) -> HttpResponseNotAllowed | TemplateResponse | HttpResponseBase:
|
|
224
221
|
try:
|
|
225
222
|
return await self.run(request=request)
|
|
226
223
|
except HTTPException as e:
|
|
@@ -240,11 +237,11 @@ class AsyncGraphQLView(
|
|
|
240
237
|
def is_websocket_request(self, request: HttpRequest) -> TypeGuard[HttpRequest]:
|
|
241
238
|
return False
|
|
242
239
|
|
|
243
|
-
async def pick_websocket_subprotocol(self, request: HttpRequest) ->
|
|
240
|
+
async def pick_websocket_subprotocol(self, request: HttpRequest) -> str | None:
|
|
244
241
|
raise NotImplementedError
|
|
245
242
|
|
|
246
243
|
async def create_websocket_response(
|
|
247
|
-
self, request: HttpRequest, subprotocol:
|
|
244
|
+
self, request: HttpRequest, subprotocol: str | None
|
|
248
245
|
) -> TemporalHttpResponse:
|
|
249
246
|
raise NotImplementedError
|
|
250
247
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from functools import cached_property
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
5
|
|
|
6
6
|
from graphql import GraphQLError
|
|
7
7
|
|
|
@@ -72,20 +72,20 @@ class InvalidTypeInputForUnion(Exception):
|
|
|
72
72
|
class MissingTypesForGenericError(Exception):
|
|
73
73
|
"""Raised when a generic types was used without passing any type."""
|
|
74
74
|
|
|
75
|
-
def __init__(self, annotation:
|
|
75
|
+
def __init__(self, annotation: StrawberryType | type) -> None:
|
|
76
76
|
message = f'The type "{annotation!r}" is generic, but no type has been passed'
|
|
77
77
|
|
|
78
78
|
super().__init__(message)
|
|
79
79
|
|
|
80
80
|
|
|
81
81
|
class UnsupportedTypeError(StrawberryException):
|
|
82
|
-
def __init__(self, annotation:
|
|
82
|
+
def __init__(self, annotation: StrawberryType | type) -> None:
|
|
83
83
|
message = f"{annotation} conversion is not supported"
|
|
84
84
|
|
|
85
85
|
super().__init__(message)
|
|
86
86
|
|
|
87
87
|
@cached_property
|
|
88
|
-
def exception_source(self) ->
|
|
88
|
+
def exception_source(self) -> ExceptionSource | None:
|
|
89
89
|
return None
|
|
90
90
|
|
|
91
91
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from functools import cached_property
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
5
|
|
|
6
6
|
from .exception import StrawberryException
|
|
7
7
|
from .utils.source_finder import SourceFinder
|
|
@@ -43,7 +43,7 @@ class ConflictingArgumentsError(StrawberryException):
|
|
|
43
43
|
)
|
|
44
44
|
|
|
45
45
|
@cached_property
|
|
46
|
-
def exception_source(self) ->
|
|
46
|
+
def exception_source(self) -> ExceptionSource | None:
|
|
47
47
|
if self.function is None:
|
|
48
48
|
return None # pragma: no cover
|
|
49
49
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from functools import cached_property
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
5
|
|
|
6
6
|
from .exception import StrawberryException
|
|
7
7
|
from .utils.source_finder import SourceFinder
|
|
@@ -17,8 +17,8 @@ class DuplicatedTypeName(StrawberryException):
|
|
|
17
17
|
|
|
18
18
|
def __init__(
|
|
19
19
|
self,
|
|
20
|
-
first_cls:
|
|
21
|
-
second_cls:
|
|
20
|
+
first_cls: type | None,
|
|
21
|
+
second_cls: type | None,
|
|
22
22
|
duplicated_type_name: str,
|
|
23
23
|
) -> None:
|
|
24
24
|
self.first_cls = first_cls
|
|
@@ -66,7 +66,7 @@ class DuplicatedTypeName(StrawberryException):
|
|
|
66
66
|
)
|
|
67
67
|
|
|
68
68
|
@cached_property
|
|
69
|
-
def exception_source(self) ->
|
|
69
|
+
def exception_source(self) -> ExceptionSource | None:
|
|
70
70
|
if self.first_cls is None:
|
|
71
71
|
return None # pragma: no cover
|
|
72
72
|
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from abc import ABC, abstractmethod
|
|
4
4
|
from functools import cached_property
|
|
5
|
-
from typing import TYPE_CHECKING
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
6
|
|
|
7
7
|
from strawberry.utils.str_converters import to_kebab_case
|
|
8
8
|
|
|
@@ -40,7 +40,7 @@ class StrawberryException(Exception, ABC):
|
|
|
40
40
|
|
|
41
41
|
@cached_property
|
|
42
42
|
@abstractmethod
|
|
43
|
-
def exception_source(self) ->
|
|
43
|
+
def exception_source(self) -> ExceptionSource | None:
|
|
44
44
|
return None
|
|
45
45
|
|
|
46
46
|
@property
|
|
@@ -61,7 +61,7 @@ class StrawberryException(Exception, ABC):
|
|
|
61
61
|
f"[link={self.documentation_url}]{self.documentation_url}"
|
|
62
62
|
).strip()
|
|
63
63
|
|
|
64
|
-
def __rich__(self) ->
|
|
64
|
+
def __rich__(self) -> RenderableType | None:
|
|
65
65
|
from rich.box import SIMPLE
|
|
66
66
|
from rich.console import Group
|
|
67
67
|
from rich.panel import Panel
|
strawberry/exceptions/handler.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import os
|
|
2
2
|
import sys
|
|
3
3
|
import threading
|
|
4
|
+
from collections.abc import Callable
|
|
4
5
|
from types import TracebackType
|
|
5
|
-
from typing import Any,
|
|
6
|
+
from typing import Any, cast
|
|
6
7
|
|
|
7
8
|
from .exception import StrawberryException, UnableToFindExceptionSource
|
|
8
9
|
|
|
@@ -10,7 +11,7 @@ original_threading_exception_hook = threading.excepthook
|
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
ExceptionHandler = Callable[
|
|
13
|
-
[type[BaseException], BaseException,
|
|
14
|
+
[type[BaseException], BaseException, TracebackType | None], None
|
|
14
15
|
]
|
|
15
16
|
|
|
16
17
|
|
|
@@ -31,7 +32,7 @@ def _get_handler(exception_type: type[BaseException]) -> ExceptionHandler:
|
|
|
31
32
|
def _handler(
|
|
32
33
|
exception_type: type[BaseException],
|
|
33
34
|
exception: BaseException,
|
|
34
|
-
traceback:
|
|
35
|
+
traceback: TracebackType | None,
|
|
35
36
|
) -> None:
|
|
36
37
|
try:
|
|
37
38
|
rich.print(exception)
|
|
@@ -49,7 +50,7 @@ def _get_handler(exception_type: type[BaseException]) -> ExceptionHandler:
|
|
|
49
50
|
def strawberry_exception_handler(
|
|
50
51
|
exception_type: type[BaseException],
|
|
51
52
|
exception: BaseException,
|
|
52
|
-
traceback:
|
|
53
|
+
traceback: TracebackType | None,
|
|
53
54
|
) -> None:
|
|
54
55
|
_get_handler(exception_type)(exception_type, exception, traceback)
|
|
55
56
|
|
|
@@ -57,9 +58,9 @@ def strawberry_exception_handler(
|
|
|
57
58
|
def strawberry_threading_exception_handler(
|
|
58
59
|
args: tuple[
|
|
59
60
|
type[BaseException],
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
BaseException | None,
|
|
62
|
+
TracebackType | None,
|
|
63
|
+
threading.Thread | None,
|
|
63
64
|
],
|
|
64
65
|
) -> None:
|
|
65
66
|
(exception_type, exception, traceback, _) = args
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from functools import cached_property
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
5
|
|
|
6
6
|
from strawberry.types.base import get_object_definition
|
|
7
7
|
|
|
@@ -55,7 +55,7 @@ class InvalidArgumentTypeError(StrawberryException):
|
|
|
55
55
|
)
|
|
56
56
|
|
|
57
57
|
@cached_property
|
|
58
|
-
def exception_source(self) ->
|
|
58
|
+
def exception_source(self) -> ExceptionSource | None:
|
|
59
59
|
if self.function is None:
|
|
60
60
|
return None # pragma: no cover
|
|
61
61
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from functools import cached_property
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
5
|
|
|
6
6
|
from .exception import StrawberryException
|
|
7
7
|
from .utils.source_finder import SourceFinder
|
|
@@ -36,6 +36,6 @@ class InvalidSuperclassInterfaceError(StrawberryException):
|
|
|
36
36
|
super().__init__(self.message)
|
|
37
37
|
|
|
38
38
|
@cached_property
|
|
39
|
-
def exception_source(self) ->
|
|
39
|
+
def exception_source(self) -> ExceptionSource | None:
|
|
40
40
|
source_finder = SourceFinder()
|
|
41
41
|
return source_finder.find_class_from_object(self.cls)
|
|
@@ -3,7 +3,7 @@ from __future__ import annotations
|
|
|
3
3
|
from functools import cached_property
|
|
4
4
|
from inspect import getframeinfo, stack
|
|
5
5
|
from pathlib import Path
|
|
6
|
-
from typing import TYPE_CHECKING
|
|
6
|
+
from typing import TYPE_CHECKING
|
|
7
7
|
|
|
8
8
|
from strawberry.exceptions.utils.source_finder import SourceFinder
|
|
9
9
|
|
|
@@ -24,7 +24,7 @@ class InvalidUnionTypeError(StrawberryException):
|
|
|
24
24
|
self,
|
|
25
25
|
union_name: str,
|
|
26
26
|
invalid_type: object,
|
|
27
|
-
union_definition:
|
|
27
|
+
union_definition: StrawberryUnion | None = None,
|
|
28
28
|
) -> None:
|
|
29
29
|
from strawberry.types.base import StrawberryList
|
|
30
30
|
from strawberry.types.scalar import ScalarWrapper
|
|
@@ -58,7 +58,7 @@ class InvalidUnionTypeError(StrawberryException):
|
|
|
58
58
|
self.annotation_message = "invalid type here"
|
|
59
59
|
|
|
60
60
|
@cached_property
|
|
61
|
-
def exception_source(self) ->
|
|
61
|
+
def exception_source(self) -> ExceptionSource | None:
|
|
62
62
|
source_finder = SourceFinder()
|
|
63
63
|
|
|
64
64
|
if self.union_definition:
|
|
@@ -100,7 +100,7 @@ class InvalidTypeForUnionMergeError(StrawberryException):
|
|
|
100
100
|
self.annotation_message = "invalid type here"
|
|
101
101
|
|
|
102
102
|
@cached_property
|
|
103
|
-
def exception_source(self) ->
|
|
103
|
+
def exception_source(self) -> ExceptionSource | None:
|
|
104
104
|
source_finder = SourceFinder()
|
|
105
105
|
|
|
106
106
|
return source_finder.find_union_merge(self.union, self.other, frame=self.frame)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from functools import cached_property
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
5
|
|
|
6
6
|
from .exception import StrawberryException
|
|
7
7
|
from .utils.source_finder import SourceFinder
|
|
@@ -52,7 +52,7 @@ class MissingArgumentsAnnotationsError(StrawberryException):
|
|
|
52
52
|
return f'arguments "{head}" and "{arguments[-1]}"'
|
|
53
53
|
|
|
54
54
|
@cached_property
|
|
55
|
-
def exception_source(self) ->
|
|
55
|
+
def exception_source(self) -> ExceptionSource | None:
|
|
56
56
|
if self.function is None:
|
|
57
57
|
return None # pragma: no cover
|
|
58
58
|
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import Optional
|
|
4
|
-
|
|
5
3
|
|
|
6
4
|
class MissingOptionalDependenciesError(Exception):
|
|
7
5
|
"""Some optional dependencies that are required for a particular task are missing."""
|
|
@@ -9,8 +7,8 @@ class MissingOptionalDependenciesError(Exception):
|
|
|
9
7
|
def __init__(
|
|
10
8
|
self,
|
|
11
9
|
*,
|
|
12
|
-
packages:
|
|
13
|
-
extras:
|
|
10
|
+
packages: list[str] | None = None,
|
|
11
|
+
extras: list[str] | None = None,
|
|
14
12
|
) -> None:
|
|
15
13
|
"""Initialize the error.
|
|
16
14
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from functools import cached_property
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
5
|
|
|
6
6
|
from .exception import StrawberryException
|
|
7
7
|
from .utils.source_finder import SourceFinder
|
|
@@ -32,7 +32,7 @@ class MissingFieldAnnotationError(StrawberryException):
|
|
|
32
32
|
super().__init__(self.message)
|
|
33
33
|
|
|
34
34
|
@cached_property
|
|
35
|
-
def exception_source(self) ->
|
|
35
|
+
def exception_source(self) -> ExceptionSource | None:
|
|
36
36
|
if self.cls is None:
|
|
37
37
|
return None # pragma: no cover
|
|
38
38
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from functools import cached_property
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
5
|
|
|
6
6
|
from .exception import StrawberryException
|
|
7
7
|
from .utils.source_finder import SourceFinder
|
|
@@ -37,7 +37,7 @@ class MissingReturnAnnotationError(StrawberryException):
|
|
|
37
37
|
self.annotation_message = "resolver missing annotation"
|
|
38
38
|
|
|
39
39
|
@cached_property
|
|
40
|
-
def exception_source(self) ->
|
|
40
|
+
def exception_source(self) -> ExceptionSource | None:
|
|
41
41
|
if self.function is None:
|
|
42
42
|
return None # pragma: no cover
|
|
43
43
|
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from enum import Enum
|
|
4
4
|
from functools import cached_property
|
|
5
|
-
from typing import TYPE_CHECKING
|
|
5
|
+
from typing import TYPE_CHECKING
|
|
6
6
|
|
|
7
7
|
from .exception import StrawberryException
|
|
8
8
|
from .utils.source_finder import SourceFinder
|
|
@@ -56,7 +56,7 @@ class ObjectIsNotClassError(StrawberryException):
|
|
|
56
56
|
return cls(obj, cls.MethodType.TYPE)
|
|
57
57
|
|
|
58
58
|
@cached_property
|
|
59
|
-
def exception_source(self) ->
|
|
59
|
+
def exception_source(self) -> ExceptionSource | None:
|
|
60
60
|
if self.function is None:
|
|
61
61
|
return None # pragma: no cover
|
|
62
62
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from functools import cached_property
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
5
|
|
|
6
6
|
from .exception import StrawberryException
|
|
7
7
|
from .utils.source_finder import SourceFinder
|
|
@@ -31,7 +31,7 @@ class ObjectIsNotAnEnumError(StrawberryException):
|
|
|
31
31
|
super().__init__(self.message)
|
|
32
32
|
|
|
33
33
|
@cached_property
|
|
34
|
-
def exception_source(self) ->
|
|
34
|
+
def exception_source(self) -> ExceptionSource | None:
|
|
35
35
|
if self.cls is None:
|
|
36
36
|
return None # pragma: no cover
|
|
37
37
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from functools import cached_property
|
|
4
|
-
from typing import TYPE_CHECKING
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
5
|
|
|
6
6
|
from .exception import StrawberryException
|
|
7
7
|
from .utils.source_finder import SourceFinder
|
|
@@ -32,7 +32,7 @@ class PermissionFailSilentlyRequiresOptionalError(StrawberryException):
|
|
|
32
32
|
super().__init__(self.message)
|
|
33
33
|
|
|
34
34
|
@cached_property
|
|
35
|
-
def exception_source(self) ->
|
|
35
|
+
def exception_source(self) -> ExceptionSource | None:
|
|
36
36
|
origin = self.field.origin
|
|
37
37
|
source_finder = SourceFinder()
|
|
38
38
|
|