strawberry-graphql 0.224.2__py3-none-any.whl → 0.225.0__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.
- strawberry/aiohttp/handlers/graphql_transport_ws_handler.py +1 -1
- strawberry/aiohttp/handlers/graphql_ws_handler.py +1 -1
- strawberry/aiohttp/views.py +2 -2
- strawberry/annotation.py +1 -1
- strawberry/arguments.py +1 -1
- strawberry/asgi/__init__.py +1 -1
- strawberry/asgi/handlers/graphql_transport_ws_handler.py +1 -1
- strawberry/asgi/handlers/graphql_ws_handler.py +1 -1
- strawberry/asgi/test/client.py +1 -1
- strawberry/auto.py +5 -5
- strawberry/chalice/views.py +2 -2
- strawberry/channels/handlers/base.py +1 -1
- strawberry/channels/handlers/graphql_transport_ws_handler.py +1 -1
- strawberry/channels/handlers/graphql_ws_handler.py +1 -1
- strawberry/channels/handlers/http_handler.py +2 -2
- strawberry/channels/handlers/ws_handler.py +1 -1
- strawberry/channels/router.py +1 -1
- strawberry/channels/testing.py +1 -1
- strawberry/codegen/query_codegen.py +2 -2
- strawberry/custom_scalar.py +2 -2
- strawberry/django/__init__.py +3 -1
- strawberry/django/context.py +1 -1
- strawberry/django/views.py +3 -3
- strawberry/exceptions/__init__.py +12 -12
- strawberry/exceptions/conflicting_arguments.py +1 -1
- strawberry/exceptions/duplicated_type_name.py +1 -1
- strawberry/exceptions/handler.py +1 -1
- strawberry/exceptions/invalid_argument_type.py +1 -1
- strawberry/exceptions/missing_arguments_annotations.py +5 -1
- strawberry/exceptions/missing_field_annotation.py +1 -1
- strawberry/exceptions/missing_return_annotation.py +5 -1
- strawberry/exceptions/not_a_strawberry_enum.py +1 -1
- strawberry/exceptions/object_is_not_a_class.py +1 -1
- strawberry/exceptions/object_is_not_an_enum.py +1 -1
- strawberry/exceptions/permission_fail_silently_requires_optional.py +1 -1
- strawberry/exceptions/private_strawberry_field.py +1 -1
- strawberry/exceptions/scalar_already_registered.py +1 -1
- strawberry/exceptions/unresolved_field_type.py +1 -1
- strawberry/experimental/pydantic/_compat.py +1 -1
- strawberry/experimental/pydantic/conversion_types.py +1 -1
- strawberry/experimental/pydantic/exceptions.py +9 -4
- strawberry/ext/mypy_plugin.py +1 -1
- strawberry/extensions/__init__.py +2 -1
- strawberry/extensions/add_validation_rules.py +1 -1
- strawberry/extensions/base_extension.py +1 -1
- strawberry/extensions/context.py +10 -8
- strawberry/extensions/disable_validation.py +1 -1
- strawberry/extensions/mask_errors.py +1 -1
- strawberry/extensions/max_aliases.py +2 -2
- strawberry/extensions/max_tokens.py +1 -1
- strawberry/extensions/parser_cache.py +1 -1
- strawberry/extensions/query_depth_limiter.py +2 -2
- strawberry/extensions/runner.py +1 -1
- strawberry/extensions/tracing/__init__.py +2 -2
- strawberry/extensions/tracing/apollo.py +1 -1
- strawberry/extensions/tracing/datadog.py +2 -2
- strawberry/extensions/tracing/opentelemetry.py +1 -1
- strawberry/extensions/tracing/sentry.py +2 -2
- strawberry/extensions/validation_cache.py +1 -1
- strawberry/fastapi/router.py +47 -5
- strawberry/federation/schema.py +1 -1
- strawberry/federation/schema_directives.py +1 -1
- strawberry/field.py +2 -2
- strawberry/flask/views.py +3 -3
- strawberry/http/exceptions.py +1 -1
- strawberry/lazy_type.py +16 -3
- strawberry/litestar/controller.py +2 -2
- strawberry/litestar/handlers/graphql_transport_ws_handler.py +1 -1
- strawberry/litestar/handlers/graphql_ws_handler.py +1 -1
- strawberry/object_type.py +3 -3
- strawberry/permission.py +1 -1
- strawberry/quart/views.py +2 -2
- strawberry/relay/exceptions.py +3 -3
- strawberry/relay/types.py +2 -2
- strawberry/sanic/views.py +2 -2
- strawberry/schema/config.py +1 -1
- strawberry/schema/exceptions.py +1 -1
- strawberry/schema/schema.py +1 -1
- strawberry/schema/schema_converter.py +7 -2
- strawberry/schema_codegen/__init__.py +2 -2
- strawberry/starlite/controller.py +6 -6
- strawberry/starlite/handlers/graphql_transport_ws_handler.py +1 -1
- strawberry/starlite/handlers/graphql_ws_handler.py +1 -1
- strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py +14 -4
- strawberry/subscriptions/protocols/graphql_ws/handlers.py +1 -1
- strawberry/test/client.py +6 -2
- strawberry/type.py +3 -3
- strawberry/types/execution.py +1 -1
- strawberry/types/fields/resolver.py +3 -3
- strawberry/types/types.py +1 -1
- strawberry/union.py +2 -2
- strawberry/unset.py +2 -2
- {strawberry_graphql-0.224.2.dist-info → strawberry_graphql-0.225.0.dist-info}/METADATA +1 -1
- {strawberry_graphql-0.224.2.dist-info → strawberry_graphql-0.225.0.dist-info}/RECORD +97 -97
- {strawberry_graphql-0.224.2.dist-info → strawberry_graphql-0.225.0.dist-info}/LICENSE +0 -0
- {strawberry_graphql-0.224.2.dist-info → strawberry_graphql-0.225.0.dist-info}/WHEEL +0 -0
- {strawberry_graphql-0.224.2.dist-info → strawberry_graphql-0.225.0.dist-info}/entry_points.txt +0 -0
@@ -1,4 +1,5 @@
|
|
1
1
|
import warnings
|
2
|
+
from typing import Type
|
2
3
|
|
3
4
|
from .add_validation_rules import AddValidationRules
|
4
5
|
from .base_extension import LifecycleStep, SchemaExtension
|
@@ -12,7 +13,7 @@ from .query_depth_limiter import IgnoreContext, QueryDepthLimiter
|
|
12
13
|
from .validation_cache import ValidationCache
|
13
14
|
|
14
15
|
|
15
|
-
def __getattr__(name: str):
|
16
|
+
def __getattr__(name: str) -> Type[SchemaExtension]:
|
16
17
|
if name == "Extension":
|
17
18
|
warnings.warn(
|
18
19
|
(
|
@@ -38,7 +38,7 @@ class AddValidationRules(SchemaExtension):
|
|
38
38
|
|
39
39
|
validation_rules: List[Type[ASTValidationRule]]
|
40
40
|
|
41
|
-
def __init__(self, validation_rules: List[Type[ASTValidationRule]]):
|
41
|
+
def __init__(self, validation_rules: List[Type[ASTValidationRule]]) -> None:
|
42
42
|
self.validation_rules = validation_rules
|
43
43
|
|
44
44
|
def on_operation(self) -> Iterator[None]:
|
@@ -21,7 +21,7 @@ class LifecycleStep(Enum):
|
|
21
21
|
class SchemaExtension:
|
22
22
|
execution_context: ExecutionContext
|
23
23
|
|
24
|
-
def __init__(self, *, execution_context: ExecutionContext):
|
24
|
+
def __init__(self, *, execution_context: ExecutionContext) -> None:
|
25
25
|
self.execution_context = execution_context
|
26
26
|
|
27
27
|
def on_operation(
|
strawberry/extensions/context.py
CHANGED
@@ -9,8 +9,10 @@ from typing import (
|
|
9
9
|
TYPE_CHECKING,
|
10
10
|
Any,
|
11
11
|
AsyncContextManager,
|
12
|
+
AsyncIterator,
|
12
13
|
Callable,
|
13
14
|
ContextManager,
|
15
|
+
Iterator,
|
14
16
|
List,
|
15
17
|
NamedTuple,
|
16
18
|
Optional,
|
@@ -42,7 +44,7 @@ class ExtensionContextManagerBase:
|
|
42
44
|
"exit_stack",
|
43
45
|
)
|
44
46
|
|
45
|
-
def __init_subclass__(cls):
|
47
|
+
def __init_subclass__(cls) -> None:
|
46
48
|
cls.DEPRECATION_MESSAGE = (
|
47
49
|
f"Event driven styled extensions for "
|
48
50
|
f"{cls.LEGACY_ENTER} or {cls.LEGACY_EXIT}"
|
@@ -54,7 +56,7 @@ class ExtensionContextManagerBase:
|
|
54
56
|
LEGACY_ENTER: str
|
55
57
|
LEGACY_EXIT: str
|
56
58
|
|
57
|
-
def __init__(self, extensions: List[SchemaExtension]):
|
59
|
+
def __init__(self, extensions: List[SchemaExtension]) -> None:
|
58
60
|
self.hooks: List[WrappedHook] = []
|
59
61
|
self.default_hook: Hook = getattr(SchemaExtension, self.HOOK_NAME)
|
60
62
|
for extension in extensions:
|
@@ -114,7 +116,7 @@ class ExtensionContextManagerBase:
|
|
114
116
|
if iscoroutinefunction(on_start) or iscoroutinefunction(on_end):
|
115
117
|
|
116
118
|
@contextlib.asynccontextmanager
|
117
|
-
async def iterator():
|
119
|
+
async def iterator() -> AsyncIterator:
|
118
120
|
if on_start:
|
119
121
|
await await_maybe(on_start())
|
120
122
|
|
@@ -128,7 +130,7 @@ class ExtensionContextManagerBase:
|
|
128
130
|
else:
|
129
131
|
|
130
132
|
@contextlib.contextmanager
|
131
|
-
def iterator_async():
|
133
|
+
def iterator_async() -> Iterator[None]:
|
132
134
|
if on_start:
|
133
135
|
on_start()
|
134
136
|
|
@@ -147,7 +149,7 @@ class ExtensionContextManagerBase:
|
|
147
149
|
if iscoroutinefunction(func):
|
148
150
|
|
149
151
|
@contextlib.asynccontextmanager
|
150
|
-
async def iterator():
|
152
|
+
async def iterator() -> AsyncIterator[None]:
|
151
153
|
await func(extension)
|
152
154
|
yield
|
153
155
|
|
@@ -155,7 +157,7 @@ class ExtensionContextManagerBase:
|
|
155
157
|
else:
|
156
158
|
|
157
159
|
@contextlib.contextmanager
|
158
|
-
def iterator():
|
160
|
+
def iterator() -> Iterator[None]:
|
159
161
|
func(extension)
|
160
162
|
yield
|
161
163
|
|
@@ -180,7 +182,7 @@ class ExtensionContextManagerBase:
|
|
180
182
|
exc_type: Optional[Type[BaseException]],
|
181
183
|
exc_val: Optional[BaseException],
|
182
184
|
exc_tb: Optional[TracebackType],
|
183
|
-
):
|
185
|
+
) -> None:
|
184
186
|
self.exit_stack.__exit__(exc_type, exc_val, exc_tb)
|
185
187
|
|
186
188
|
async def __aenter__(self) -> None:
|
@@ -199,7 +201,7 @@ class ExtensionContextManagerBase:
|
|
199
201
|
exc_type: Optional[Type[BaseException]],
|
200
202
|
exc_val: Optional[BaseException],
|
201
203
|
exc_tb: Optional[TracebackType],
|
202
|
-
):
|
204
|
+
) -> None:
|
203
205
|
await self.async_exit_stack.__aexit__(exc_type, exc_val, exc_tb)
|
204
206
|
|
205
207
|
|
@@ -18,7 +18,7 @@ class MaskErrors(SchemaExtension):
|
|
18
18
|
self,
|
19
19
|
should_mask_error: Callable[[GraphQLError], bool] = default_should_mask_error,
|
20
20
|
error_message: str = "Unexpected error.",
|
21
|
-
):
|
21
|
+
) -> None:
|
22
22
|
self.should_mask_error = should_mask_error
|
23
23
|
self.error_message = error_message
|
24
24
|
|
@@ -37,14 +37,14 @@ class MaxAliasesLimiter(AddValidationRules):
|
|
37
37
|
def __init__(
|
38
38
|
self,
|
39
39
|
max_alias_count: int,
|
40
|
-
):
|
40
|
+
) -> None:
|
41
41
|
validator = create_validator(max_alias_count)
|
42
42
|
super().__init__([validator])
|
43
43
|
|
44
44
|
|
45
45
|
def create_validator(max_alias_count: int) -> Type[ValidationRule]:
|
46
46
|
class MaxAliasesValidator(ValidationRule):
|
47
|
-
def __init__(self, validation_context: ValidationContext):
|
47
|
+
def __init__(self, validation_context: ValidationContext) -> None:
|
48
48
|
document = validation_context.document
|
49
49
|
def_that_can_contain_alias = (
|
50
50
|
def_
|
@@ -30,7 +30,7 @@ class ParserCache(SchemaExtension):
|
|
30
30
|
|
31
31
|
"""
|
32
32
|
|
33
|
-
def __init__(self, maxsize: Optional[int] = None):
|
33
|
+
def __init__(self, maxsize: Optional[int] = None) -> None:
|
34
34
|
self.cached_parse_document = lru_cache(maxsize=maxsize)(parse_document)
|
35
35
|
|
36
36
|
def on_parse(self) -> Iterator[None]:
|
@@ -114,7 +114,7 @@ class QueryDepthLimiter(AddValidationRules):
|
|
114
114
|
max_depth: int,
|
115
115
|
callback: Optional[Callable[[Dict[str, int]], None]] = None,
|
116
116
|
should_ignore: Optional[ShouldIgnoreType] = None,
|
117
|
-
):
|
117
|
+
) -> None:
|
118
118
|
if should_ignore is not None and not callable(should_ignore):
|
119
119
|
raise TypeError(
|
120
120
|
"The `should_ignore` argument to "
|
@@ -130,7 +130,7 @@ def create_validator(
|
|
130
130
|
callback: Optional[Callable[[Dict[str, int]], None]] = None,
|
131
131
|
) -> Type[ValidationRule]:
|
132
132
|
class DepthLimitValidator(ValidationRule):
|
133
|
-
def __init__(self, validation_context: ValidationContext):
|
133
|
+
def __init__(self, validation_context: ValidationContext) -> None:
|
134
134
|
document = validation_context.document
|
135
135
|
definitions = document.definitions
|
136
136
|
|
strawberry/extensions/runner.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import importlib
|
2
|
-
from typing import TYPE_CHECKING
|
2
|
+
from typing import TYPE_CHECKING, Any
|
3
3
|
|
4
4
|
if TYPE_CHECKING:
|
5
5
|
from .apollo import ApolloTracingExtension, ApolloTracingExtensionSync
|
@@ -22,7 +22,7 @@ __all__ = [
|
|
22
22
|
]
|
23
23
|
|
24
24
|
|
25
|
-
def __getattr__(name: str):
|
25
|
+
def __getattr__(name: str) -> Any:
|
26
26
|
if name in {"DatadogTracingExtension", "DatadogTracingExtensionSync"}:
|
27
27
|
return getattr(importlib.import_module(".datadog", __name__), name)
|
28
28
|
|
@@ -80,7 +80,7 @@ class ApolloTracingStats:
|
|
80
80
|
|
81
81
|
|
82
82
|
class ApolloTracingExtension(SchemaExtension):
|
83
|
-
def __init__(self, execution_context: ExecutionContext):
|
83
|
+
def __init__(self, execution_context: ExecutionContext) -> None:
|
84
84
|
self._resolver_stats: List[ApolloResolverStats] = []
|
85
85
|
self.execution_context = execution_context
|
86
86
|
|
@@ -21,12 +21,12 @@ class DatadogTracingExtension(SchemaExtension):
|
|
21
21
|
self,
|
22
22
|
*,
|
23
23
|
execution_context: Optional[ExecutionContext] = None,
|
24
|
-
):
|
24
|
+
) -> None:
|
25
25
|
if execution_context:
|
26
26
|
self.execution_context = execution_context
|
27
27
|
|
28
28
|
@cached_property
|
29
|
-
def _resource_name(self):
|
29
|
+
def _resource_name(self) -> str:
|
30
30
|
assert self.execution_context.query
|
31
31
|
|
32
32
|
query_hash = self.hash_query(self.execution_context.query)
|
@@ -45,7 +45,7 @@ class OpenTelemetryExtension(SchemaExtension):
|
|
45
45
|
*,
|
46
46
|
execution_context: Optional[ExecutionContext] = None,
|
47
47
|
arg_filter: Optional[ArgFilter] = None,
|
48
|
-
):
|
48
|
+
) -> None:
|
49
49
|
self._arg_filter = arg_filter
|
50
50
|
self._tracer = trace.get_tracer("strawberry")
|
51
51
|
if execution_context:
|
@@ -22,7 +22,7 @@ class SentryTracingExtension(SchemaExtension):
|
|
22
22
|
self,
|
23
23
|
*,
|
24
24
|
execution_context: Optional[ExecutionContext] = None,
|
25
|
-
):
|
25
|
+
) -> None:
|
26
26
|
warnings.warn(
|
27
27
|
"The Sentry tracing extension is deprecated, please update to sentry>=1.32.0",
|
28
28
|
DeprecationWarning,
|
@@ -33,7 +33,7 @@ class SentryTracingExtension(SchemaExtension):
|
|
33
33
|
self.execution_context = execution_context
|
34
34
|
|
35
35
|
@cached_property
|
36
|
-
def _resource_name(self):
|
36
|
+
def _resource_name(self) -> str:
|
37
37
|
assert self.execution_context.query
|
38
38
|
|
39
39
|
query_hash = self.hash_query(self.execution_context.query)
|
@@ -30,7 +30,7 @@ class ValidationCache(SchemaExtension):
|
|
30
30
|
|
31
31
|
"""
|
32
32
|
|
33
|
-
def __init__(self, maxsize: Optional[int] = None):
|
33
|
+
def __init__(self, maxsize: Optional[int] = None) -> None:
|
34
34
|
self.cached_validate_document = lru_cache(maxsize=maxsize)(validate_document)
|
35
35
|
|
36
36
|
def on_validate(self) -> Iterator[None]:
|
strawberry/fastapi/router.py
CHANGED
@@ -8,9 +8,12 @@ from typing import (
|
|
8
8
|
Any,
|
9
9
|
Awaitable,
|
10
10
|
Callable,
|
11
|
+
Dict,
|
12
|
+
List,
|
11
13
|
Mapping,
|
12
14
|
Optional,
|
13
15
|
Sequence,
|
16
|
+
Type,
|
14
17
|
Union,
|
15
18
|
cast,
|
16
19
|
)
|
@@ -20,12 +23,16 @@ from starlette.background import BackgroundTasks # noqa: TCH002
|
|
20
23
|
from starlette.requests import HTTPConnection, Request
|
21
24
|
from starlette.responses import (
|
22
25
|
HTMLResponse,
|
26
|
+
JSONResponse,
|
23
27
|
PlainTextResponse,
|
24
28
|
Response,
|
25
29
|
)
|
26
30
|
from starlette.websockets import WebSocket
|
27
31
|
|
28
|
-
from fastapi import APIRouter, Depends
|
32
|
+
from fastapi import APIRouter, Depends, params
|
33
|
+
from fastapi.datastructures import Default
|
34
|
+
from fastapi.routing import APIRoute
|
35
|
+
from fastapi.utils import generate_unique_id
|
29
36
|
from strawberry.exceptions import InvalidCustomContext
|
30
37
|
from strawberry.fastapi.context import BaseContext, CustomContext
|
31
38
|
from strawberry.fastapi.handlers import GraphQLTransportWSHandler, GraphQLWSHandler
|
@@ -42,7 +49,10 @@ from strawberry.http.typevars import (
|
|
42
49
|
from strawberry.subscriptions import GRAPHQL_TRANSPORT_WS_PROTOCOL, GRAPHQL_WS_PROTOCOL
|
43
50
|
|
44
51
|
if TYPE_CHECKING:
|
45
|
-
from
|
52
|
+
from enum import Enum
|
53
|
+
|
54
|
+
from starlette.routing import BaseRoute
|
55
|
+
from starlette.types import ASGIApp, Lifespan
|
46
56
|
|
47
57
|
from strawberry.fastapi.context import MergedContext
|
48
58
|
from strawberry.http import GraphQLHTTPResponse
|
@@ -52,7 +62,7 @@ if TYPE_CHECKING:
|
|
52
62
|
|
53
63
|
|
54
64
|
class FastAPIRequestAdapter(AsyncHTTPRequestAdapter):
|
55
|
-
def __init__(self, request: Request):
|
65
|
+
def __init__(self, request: Request) -> None:
|
56
66
|
self.request = request
|
57
67
|
|
58
68
|
@property
|
@@ -89,7 +99,7 @@ class GraphQLRouter(
|
|
89
99
|
request_adapter_class = FastAPIRequestAdapter
|
90
100
|
|
91
101
|
@staticmethod
|
92
|
-
async def __get_root_value():
|
102
|
+
async def __get_root_value() -> None:
|
93
103
|
return None
|
94
104
|
|
95
105
|
@staticmethod
|
@@ -160,14 +170,46 @@ class GraphQLRouter(
|
|
160
170
|
GRAPHQL_WS_PROTOCOL,
|
161
171
|
),
|
162
172
|
connection_init_wait_timeout: timedelta = timedelta(minutes=1),
|
173
|
+
prefix: str = "",
|
174
|
+
tags: Optional[List[Union[str, Enum]]] = None,
|
175
|
+
dependencies: Optional[Sequence[params.Depends]] = None,
|
176
|
+
default_response_class: Type[Response] = Default(JSONResponse),
|
177
|
+
responses: Optional[Dict[Union[int, str], Dict[str, Any]]] = None,
|
178
|
+
callbacks: Optional[List[BaseRoute]] = None,
|
179
|
+
routes: Optional[List[BaseRoute]] = None,
|
180
|
+
redirect_slashes: bool = True,
|
163
181
|
default: Optional[ASGIApp] = None,
|
182
|
+
dependency_overrides_provider: Optional[Any] = None,
|
183
|
+
route_class: Type[APIRoute] = APIRoute,
|
164
184
|
on_startup: Optional[Sequence[Callable[[], Any]]] = None,
|
165
185
|
on_shutdown: Optional[Sequence[Callable[[], Any]]] = None,
|
166
|
-
|
186
|
+
lifespan: Optional[Lifespan[Any]] = None,
|
187
|
+
deprecated: Optional[bool] = None,
|
188
|
+
include_in_schema: bool = True,
|
189
|
+
generate_unique_id_function: Callable[[APIRoute], str] = Default(
|
190
|
+
generate_unique_id
|
191
|
+
),
|
192
|
+
**kwargs: Any,
|
193
|
+
) -> None:
|
167
194
|
super().__init__(
|
195
|
+
prefix=prefix,
|
196
|
+
tags=tags,
|
197
|
+
dependencies=dependencies,
|
198
|
+
default_response_class=default_response_class,
|
199
|
+
responses=responses,
|
200
|
+
callbacks=callbacks,
|
201
|
+
routes=routes,
|
202
|
+
redirect_slashes=redirect_slashes,
|
168
203
|
default=default,
|
204
|
+
dependency_overrides_provider=dependency_overrides_provider,
|
205
|
+
route_class=route_class,
|
169
206
|
on_startup=on_startup,
|
170
207
|
on_shutdown=on_shutdown,
|
208
|
+
lifespan=lifespan,
|
209
|
+
deprecated=deprecated,
|
210
|
+
include_in_schema=include_in_schema,
|
211
|
+
generate_unique_id_function=generate_unique_id_function,
|
212
|
+
**kwargs,
|
171
213
|
)
|
172
214
|
self.schema = schema
|
173
215
|
self.allow_queries_via_get = allow_queries_via_get
|
strawberry/federation/schema.py
CHANGED
strawberry/field.py
CHANGED
@@ -90,7 +90,7 @@ class StrawberryField(dataclasses.Field):
|
|
90
90
|
deprecation_reason: Optional[str] = None,
|
91
91
|
directives: Sequence[object] = (),
|
92
92
|
extensions: List[FieldExtension] = (), # type: ignore
|
93
|
-
):
|
93
|
+
) -> None:
|
94
94
|
# basic fields are fields with no provided resolver
|
95
95
|
is_basic_field = not base_resolver
|
96
96
|
|
@@ -242,7 +242,7 @@ class StrawberryField(dataclasses.Field):
|
|
242
242
|
return self._arguments
|
243
243
|
|
244
244
|
@arguments.setter
|
245
|
-
def arguments(self, value: List[StrawberryArgument]):
|
245
|
+
def arguments(self, value: List[StrawberryArgument]) -> None:
|
246
246
|
self._arguments = value
|
247
247
|
|
248
248
|
@property
|
strawberry/flask/views.py
CHANGED
@@ -22,7 +22,7 @@ if TYPE_CHECKING:
|
|
22
22
|
|
23
23
|
|
24
24
|
class FlaskHTTPRequestAdapter(SyncHTTPRequestAdapter):
|
25
|
-
def __init__(self, request: Request):
|
25
|
+
def __init__(self, request: Request) -> None:
|
26
26
|
self.request = request
|
27
27
|
|
28
28
|
@property
|
@@ -64,7 +64,7 @@ class BaseGraphQLView:
|
|
64
64
|
graphiql: Optional[bool] = None,
|
65
65
|
graphql_ide: Optional[GraphQL_IDE] = "graphiql",
|
66
66
|
allow_queries_via_get: bool = True,
|
67
|
-
):
|
67
|
+
) -> None:
|
68
68
|
self.schema = schema
|
69
69
|
self.graphiql = graphiql
|
70
70
|
self.allow_queries_via_get = allow_queries_via_get
|
@@ -119,7 +119,7 @@ class GraphQLView(
|
|
119
119
|
|
120
120
|
|
121
121
|
class AsyncFlaskHTTPRequestAdapter(AsyncHTTPRequestAdapter):
|
122
|
-
def __init__(self, request: Request):
|
122
|
+
def __init__(self, request: Request) -> None:
|
123
123
|
self.request = request
|
124
124
|
|
125
125
|
@property
|
strawberry/http/exceptions.py
CHANGED
strawberry/lazy_type.py
CHANGED
@@ -4,7 +4,20 @@ import sys
|
|
4
4
|
import warnings
|
5
5
|
from dataclasses import dataclass
|
6
6
|
from pathlib import Path
|
7
|
-
from typing import
|
7
|
+
from typing import (
|
8
|
+
TYPE_CHECKING,
|
9
|
+
Any,
|
10
|
+
ForwardRef,
|
11
|
+
Generic,
|
12
|
+
Optional,
|
13
|
+
Tuple,
|
14
|
+
Type,
|
15
|
+
TypeVar,
|
16
|
+
cast,
|
17
|
+
)
|
18
|
+
|
19
|
+
if TYPE_CHECKING:
|
20
|
+
from typing_extensions import Self
|
8
21
|
|
9
22
|
TypeName = TypeVar("TypeName")
|
10
23
|
Module = TypeVar("Module")
|
@@ -16,7 +29,7 @@ class LazyType(Generic[TypeName, Module]):
|
|
16
29
|
module: str
|
17
30
|
package: Optional[str] = None
|
18
31
|
|
19
|
-
def __class_getitem__(cls, params: Tuple[str, str]):
|
32
|
+
def __class_getitem__(cls, params: Tuple[str, str]) -> "Self":
|
20
33
|
warnings.warn(
|
21
34
|
(
|
22
35
|
"LazyType is deprecated, use "
|
@@ -63,7 +76,7 @@ class LazyType(Generic[TypeName, Module]):
|
|
63
76
|
# this empty call method allows LazyTypes to be used in generic types
|
64
77
|
# for example: List[LazyType["A", "module"]]
|
65
78
|
|
66
|
-
def __call__(self): # pragma: no cover
|
79
|
+
def __call__(self) -> None: # pragma: no cover
|
67
80
|
return None
|
68
81
|
|
69
82
|
|
@@ -325,10 +325,10 @@ class GraphQLController(
|
|
325
325
|
context_ws: Any,
|
326
326
|
root_value: Any,
|
327
327
|
) -> None:
|
328
|
-
async def _get_context():
|
328
|
+
async def _get_context() -> Any:
|
329
329
|
return context_ws
|
330
330
|
|
331
|
-
async def _get_root_value():
|
331
|
+
async def _get_root_value() -> Any:
|
332
332
|
return root_value
|
333
333
|
|
334
334
|
preferred_protocol = self.pick_preferred_protocol(socket)
|
@@ -20,7 +20,7 @@ class GraphQLTransportWSHandler(BaseGraphQLTransportWSHandler):
|
|
20
20
|
get_context: Callable,
|
21
21
|
get_root_value: Callable,
|
22
22
|
ws: WebSocket,
|
23
|
-
):
|
23
|
+
) -> None:
|
24
24
|
super().__init__(schema, debug, connection_init_wait_timeout)
|
25
25
|
self._get_context = get_context
|
26
26
|
self._get_root_value = get_root_value
|
@@ -20,7 +20,7 @@ class GraphQLWSHandler(BaseGraphQLWSHandler):
|
|
20
20
|
get_context: Callable,
|
21
21
|
get_root_value: Callable,
|
22
22
|
ws: WebSocket,
|
23
|
-
):
|
23
|
+
) -> None:
|
24
24
|
super().__init__(schema, debug, keep_alive, keep_alive_interval)
|
25
25
|
self._get_context = get_context
|
26
26
|
self._get_root_value = get_root_value
|
strawberry/object_type.py
CHANGED
@@ -125,7 +125,7 @@ def _wrap_dataclass(cls: Type[Any]):
|
|
125
125
|
|
126
126
|
|
127
127
|
def _process_type(
|
128
|
-
cls:
|
128
|
+
cls: T,
|
129
129
|
*,
|
130
130
|
name: Optional[str] = None,
|
131
131
|
is_input: bool = False,
|
@@ -133,7 +133,7 @@ def _process_type(
|
|
133
133
|
description: Optional[str] = None,
|
134
134
|
directives: Optional[Sequence[object]] = (),
|
135
135
|
extend: bool = False,
|
136
|
-
):
|
136
|
+
) -> T:
|
137
137
|
name = name or to_camel_case(cls.__name__)
|
138
138
|
|
139
139
|
interfaces = _get_interfaces(cls)
|
@@ -237,7 +237,7 @@ def type(
|
|
237
237
|
>>> field_abc: str = "ABC"
|
238
238
|
"""
|
239
239
|
|
240
|
-
def wrap(cls: Type):
|
240
|
+
def wrap(cls: Type) -> T:
|
241
241
|
if not inspect.isclass(cls):
|
242
242
|
if is_input:
|
243
243
|
exc = ObjectIsNotClassError.input
|
strawberry/permission.py
CHANGED
@@ -109,7 +109,7 @@ class PermissionExtension(FieldExtension):
|
|
109
109
|
permissions: List[BasePermission],
|
110
110
|
use_directives: bool = True,
|
111
111
|
fail_silently: bool = False,
|
112
|
-
):
|
112
|
+
) -> None:
|
113
113
|
self.permissions = permissions
|
114
114
|
self.fail_silently = fail_silently
|
115
115
|
self.return_empty_list = False
|
strawberry/quart/views.py
CHANGED
@@ -17,7 +17,7 @@ if TYPE_CHECKING:
|
|
17
17
|
|
18
18
|
|
19
19
|
class QuartHTTPRequestAdapter(AsyncHTTPRequestAdapter):
|
20
|
-
def __init__(self, request: Request):
|
20
|
+
def __init__(self, request: Request) -> None:
|
21
21
|
self.request = request
|
22
22
|
|
23
23
|
@property
|
@@ -61,7 +61,7 @@ class GraphQLView(
|
|
61
61
|
graphiql: Optional[bool] = None,
|
62
62
|
graphql_ide: Optional[GraphQL_IDE] = "graphiql",
|
63
63
|
allow_queries_via_get: bool = True,
|
64
|
-
):
|
64
|
+
) -> None:
|
65
65
|
self.schema = schema
|
66
66
|
self.allow_queries_via_get = allow_queries_via_get
|
67
67
|
|
strawberry/relay/exceptions.py
CHANGED
@@ -13,7 +13,7 @@ if TYPE_CHECKING:
|
|
13
13
|
|
14
14
|
|
15
15
|
class NodeIDAnnotationError(StrawberryException):
|
16
|
-
def __init__(self, message: str, cls: Type):
|
16
|
+
def __init__(self, message: str, cls: Type) -> None:
|
17
17
|
self.cls = cls
|
18
18
|
|
19
19
|
self.message = message
|
@@ -41,7 +41,7 @@ class NodeIDAnnotationError(StrawberryException):
|
|
41
41
|
|
42
42
|
|
43
43
|
class RelayWrongAnnotationError(StrawberryException):
|
44
|
-
def __init__(self, field_name: str, cls: Type):
|
44
|
+
def __init__(self, field_name: str, cls: Type) -> None:
|
45
45
|
self.cls = cls
|
46
46
|
self.field_name = field_name
|
47
47
|
|
@@ -71,7 +71,7 @@ class RelayWrongAnnotationError(StrawberryException):
|
|
71
71
|
|
72
72
|
|
73
73
|
class RelayWrongResolverAnnotationError(StrawberryException):
|
74
|
-
def __init__(self, field_name: str, resolver: StrawberryResolver):
|
74
|
+
def __init__(self, field_name: str, resolver: StrawberryResolver) -> None:
|
75
75
|
self.function = resolver.wrapped_func
|
76
76
|
self.field_name = field_name
|
77
77
|
|
strawberry/relay/types.py
CHANGED
@@ -86,7 +86,7 @@ class GlobalID:
|
|
86
86
|
type_name: str
|
87
87
|
node_id: str
|
88
88
|
|
89
|
-
def __post_init__(self):
|
89
|
+
def __post_init__(self) -> None:
|
90
90
|
if not isinstance(self.type_name, str):
|
91
91
|
raise GlobalIDValueError(
|
92
92
|
f"type_name is expected to be a string, found {self.type_name!r}"
|
@@ -96,7 +96,7 @@ class GlobalID:
|
|
96
96
|
f"node_id is expected to be a string, found {self.node_id!r}"
|
97
97
|
)
|
98
98
|
|
99
|
-
def __str__(self):
|
99
|
+
def __str__(self) -> str:
|
100
100
|
return to_base64(self.type_name, self.node_id)
|
101
101
|
|
102
102
|
@classmethod
|
strawberry/sanic/views.py
CHANGED
@@ -33,7 +33,7 @@ if TYPE_CHECKING:
|
|
33
33
|
|
34
34
|
|
35
35
|
class SanicHTTPRequestAdapter(AsyncHTTPRequestAdapter):
|
36
|
-
def __init__(self, request: Request):
|
36
|
+
def __init__(self, request: Request) -> None:
|
37
37
|
self.request = request
|
38
38
|
|
39
39
|
@property
|
@@ -107,7 +107,7 @@ class GraphQLView(
|
|
107
107
|
allow_queries_via_get: bool = True,
|
108
108
|
json_encoder: Optional[Type[json.JSONEncoder]] = None,
|
109
109
|
json_dumps_params: Optional[Dict[str, Any]] = None,
|
110
|
-
):
|
110
|
+
) -> None:
|
111
111
|
self.schema = schema
|
112
112
|
self.allow_queries_via_get = allow_queries_via_get
|
113
113
|
self.json_encoder = json_encoder
|