strawberry-graphql 0.283.2__py3-none-any.whl → 0.284.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/views.py +2 -3
- strawberry/annotation.py +6 -9
- strawberry/asgi/__init__.py +8 -3
- strawberry/asgi/test/client.py +1 -1
- strawberry/channels/handlers/base.py +3 -3
- strawberry/channels/handlers/http_handler.py +3 -3
- strawberry/channels/handlers/ws_handler.py +1 -1
- strawberry/cli/commands/upgrade/__init__.py +1 -3
- strawberry/codegen/query_codegen.py +1 -2
- strawberry/codegen/types.py +1 -1
- strawberry/dataloader.py +9 -3
- strawberry/directive.py +1 -1
- strawberry/django/views.py +2 -3
- strawberry/exceptions/handler.py +2 -1
- strawberry/exceptions/utils/source_finder.py +2 -2
- strawberry/experimental/pydantic/_compat.py +3 -2
- strawberry/experimental/pydantic/error_type.py +1 -2
- strawberry/experimental/pydantic/fields.py +8 -14
- strawberry/experimental/pydantic/object_type.py +1 -9
- strawberry/ext/mypy_plugin.py +2 -1
- strawberry/extensions/base_extension.py +2 -1
- strawberry/extensions/context.py +1 -2
- strawberry/extensions/directives.py +3 -1
- strawberry/extensions/field_extension.py +3 -3
- strawberry/extensions/query_depth_limiter.py +1 -1
- strawberry/extensions/tracing/apollo.py +2 -2
- strawberry/extensions/tracing/datadog.py +2 -2
- strawberry/extensions/tracing/opentelemetry.py +1 -1
- strawberry/extensions/tracing/utils.py +3 -1
- strawberry/fastapi/router.py +2 -2
- strawberry/federation/enum.py +1 -2
- strawberry/federation/field.py +2 -3
- strawberry/federation/object_type.py +1 -2
- strawberry/federation/scalar.py +2 -8
- strawberry/federation/schema_directive.py +2 -1
- strawberry/flask/views.py +1 -1
- strawberry/http/__init__.py +2 -2
- strawberry/http/async_base_view.py +2 -3
- strawberry/http/ides.py +1 -2
- strawberry/http/sync_base_view.py +1 -1
- strawberry/http/types.py +2 -2
- strawberry/litestar/controller.py +8 -3
- strawberry/printer/printer.py +2 -1
- strawberry/quart/views.py +2 -3
- strawberry/relay/fields.py +5 -3
- strawberry/relay/types.py +5 -1
- strawberry/resolvers.py +2 -1
- strawberry/sanic/views.py +2 -3
- strawberry/schema/compat.py +1 -1
- strawberry/schema/config.py +4 -1
- strawberry/schema/schema.py +2 -3
- strawberry/schema/schema_converter.py +9 -2
- strawberry/schema/types/base_scalars.py +1 -1
- strawberry/schema_codegen/__init__.py +2 -2
- strawberry/schema_directive.py +2 -1
- strawberry/subscriptions/protocols/graphql_transport_ws/types.py +2 -2
- strawberry/subscriptions/protocols/graphql_ws/types.py +2 -2
- strawberry/test/client.py +2 -2
- strawberry/types/arguments.py +2 -1
- strawberry/types/auto.py +1 -2
- strawberry/types/base.py +7 -5
- strawberry/types/enum.py +1 -2
- strawberry/types/field.py +6 -8
- strawberry/types/fields/resolver.py +3 -3
- strawberry/types/maybe.py +1 -2
- strawberry/types/mutation.py +3 -4
- strawberry/types/object_type.py +2 -21
- strawberry/types/scalar.py +2 -7
- strawberry/types/union.py +1 -1
- strawberry/utils/aio.py +7 -2
- strawberry/utils/inspect.py +2 -2
- strawberry/utils/typing.py +8 -68
- {strawberry_graphql-0.283.2.dist-info → strawberry_graphql-0.284.0.dist-info}/METADATA +2 -2
- {strawberry_graphql-0.283.2.dist-info → strawberry_graphql-0.284.0.dist-info}/RECORD +77 -78
- strawberry/utils/dataclasses.py +0 -37
- {strawberry_graphql-0.283.2.dist-info → strawberry_graphql-0.284.0.dist-info}/WHEEL +0 -0
- {strawberry_graphql-0.283.2.dist-info → strawberry_graphql-0.284.0.dist-info}/entry_points.txt +0 -0
- {strawberry_graphql-0.283.2.dist-info → strawberry_graphql-0.284.0.dist-info}/licenses/LICENSE +0 -0
strawberry/flask/views.py
CHANGED
strawberry/http/__init__.py
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
|
-
from typing import Any, Optional
|
|
5
|
-
from typing_extensions import
|
|
4
|
+
from typing import Any, Literal, Optional
|
|
5
|
+
from typing_extensions import TypedDict
|
|
6
6
|
|
|
7
7
|
from strawberry.schema._graphql_core import (
|
|
8
8
|
GraphQLIncrementalExecutionResults,
|
|
@@ -2,19 +2,18 @@ import abc
|
|
|
2
2
|
import asyncio
|
|
3
3
|
import contextlib
|
|
4
4
|
import json
|
|
5
|
-
from collections.abc import AsyncGenerator, Mapping
|
|
5
|
+
from collections.abc import AsyncGenerator, Callable, Mapping
|
|
6
6
|
from datetime import timedelta
|
|
7
7
|
from typing import (
|
|
8
8
|
Any,
|
|
9
|
-
Callable,
|
|
10
9
|
Generic,
|
|
11
10
|
Literal,
|
|
12
11
|
Optional,
|
|
12
|
+
TypeGuard,
|
|
13
13
|
Union,
|
|
14
14
|
cast,
|
|
15
15
|
overload,
|
|
16
16
|
)
|
|
17
|
-
from typing_extensions import TypeGuard
|
|
18
17
|
|
|
19
18
|
from graphql import GraphQLError
|
|
20
19
|
from lia import AsyncHTTPRequestAdapter, HTTPException
|
strawberry/http/ides.py
CHANGED
strawberry/http/types.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
from collections.abc import Mapping
|
|
2
|
-
from typing import Any, Optional
|
|
3
|
-
from typing_extensions import
|
|
2
|
+
from typing import Any, Literal, Optional
|
|
3
|
+
from typing_extensions import TypedDict
|
|
4
4
|
|
|
5
5
|
HTTPMethod = Literal[
|
|
6
6
|
"GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "TRACE"
|
|
@@ -8,13 +8,12 @@ from datetime import timedelta
|
|
|
8
8
|
from typing import (
|
|
9
9
|
TYPE_CHECKING,
|
|
10
10
|
Any,
|
|
11
|
-
Callable,
|
|
12
11
|
ClassVar,
|
|
13
12
|
Optional,
|
|
14
13
|
TypedDict,
|
|
14
|
+
TypeGuard,
|
|
15
15
|
Union,
|
|
16
16
|
)
|
|
17
|
-
from typing_extensions import TypeGuard
|
|
18
17
|
|
|
19
18
|
from lia import HTTPException, LitestarRequestAdapter
|
|
20
19
|
from msgspec import Struct
|
|
@@ -52,7 +51,13 @@ from strawberry.http.typevars import Context, RootValue
|
|
|
52
51
|
from strawberry.subscriptions import GRAPHQL_TRANSPORT_WS_PROTOCOL, GRAPHQL_WS_PROTOCOL
|
|
53
52
|
|
|
54
53
|
if TYPE_CHECKING:
|
|
55
|
-
from collections.abc import
|
|
54
|
+
from collections.abc import (
|
|
55
|
+
AsyncGenerator,
|
|
56
|
+
AsyncIterator,
|
|
57
|
+
Callable,
|
|
58
|
+
Mapping,
|
|
59
|
+
Sequence,
|
|
60
|
+
)
|
|
56
61
|
|
|
57
62
|
from litestar.types import AnyCallable, Dependencies
|
|
58
63
|
from strawberry.http import GraphQLHTTPResponse
|
strawberry/printer/printer.py
CHANGED
|
@@ -5,7 +5,6 @@ from itertools import chain
|
|
|
5
5
|
from typing import (
|
|
6
6
|
TYPE_CHECKING,
|
|
7
7
|
Any,
|
|
8
|
-
Callable,
|
|
9
8
|
Optional,
|
|
10
9
|
TypeVar,
|
|
11
10
|
Union,
|
|
@@ -46,6 +45,8 @@ from strawberry.types.unset import UNSET
|
|
|
46
45
|
from .ast_from_value import ast_from_value
|
|
47
46
|
|
|
48
47
|
if TYPE_CHECKING:
|
|
48
|
+
from collections.abc import Callable
|
|
49
|
+
|
|
49
50
|
from graphql import (
|
|
50
51
|
GraphQLArgument,
|
|
51
52
|
GraphQLEnumType,
|
strawberry/quart/views.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import warnings
|
|
3
|
-
from collections.abc import AsyncGenerator, Mapping, Sequence
|
|
3
|
+
from collections.abc import AsyncGenerator, Callable, Mapping, Sequence
|
|
4
4
|
from datetime import timedelta
|
|
5
5
|
from json.decoder import JSONDecodeError
|
|
6
|
-
from typing import TYPE_CHECKING,
|
|
7
|
-
from typing_extensions import TypeGuard
|
|
6
|
+
from typing import TYPE_CHECKING, ClassVar, Optional, TypeGuard, Union
|
|
8
7
|
|
|
9
8
|
from lia import HTTPException, QuartHTTPRequestAdapter
|
|
10
9
|
|
strawberry/relay/fields.py
CHANGED
|
@@ -8,6 +8,7 @@ from collections.abc import (
|
|
|
8
8
|
AsyncIterable,
|
|
9
9
|
AsyncIterator,
|
|
10
10
|
Awaitable,
|
|
11
|
+
Callable,
|
|
11
12
|
Iterable,
|
|
12
13
|
Iterator,
|
|
13
14
|
Mapping,
|
|
@@ -17,13 +18,13 @@ from typing import (
|
|
|
17
18
|
TYPE_CHECKING,
|
|
18
19
|
Annotated,
|
|
19
20
|
Any,
|
|
20
|
-
Callable,
|
|
21
21
|
ForwardRef,
|
|
22
22
|
Optional,
|
|
23
23
|
Union,
|
|
24
24
|
cast,
|
|
25
|
+
get_args,
|
|
26
|
+
get_origin,
|
|
25
27
|
)
|
|
26
|
-
from typing_extensions import get_args, get_origin
|
|
27
28
|
|
|
28
29
|
from strawberry.annotation import StrawberryAnnotation
|
|
29
30
|
from strawberry.extensions.field_extension import (
|
|
@@ -47,7 +48,7 @@ from strawberry.utils.typing import eval_type, is_generic_alias, is_optional, is
|
|
|
47
48
|
from .types import Connection, GlobalID, Node
|
|
48
49
|
|
|
49
50
|
if TYPE_CHECKING:
|
|
50
|
-
from
|
|
51
|
+
from typing import Literal
|
|
51
52
|
|
|
52
53
|
from strawberry.permission import BasePermission
|
|
53
54
|
from strawberry.types.info import Info
|
|
@@ -180,6 +181,7 @@ class NodeExtension(FieldExtension):
|
|
|
180
181
|
for nodes in asyncgen_nodes.values()
|
|
181
182
|
),
|
|
182
183
|
),
|
|
184
|
+
strict=True,
|
|
183
185
|
)
|
|
184
186
|
)
|
|
185
187
|
|
strawberry/relay/types.py
CHANGED
|
@@ -19,13 +19,17 @@ from typing import (
|
|
|
19
19
|
ClassVar,
|
|
20
20
|
ForwardRef,
|
|
21
21
|
Generic,
|
|
22
|
+
Literal,
|
|
22
23
|
Optional,
|
|
24
|
+
TypeAlias,
|
|
23
25
|
TypeVar,
|
|
24
26
|
Union,
|
|
25
27
|
cast,
|
|
28
|
+
get_args,
|
|
29
|
+
get_origin,
|
|
26
30
|
overload,
|
|
27
31
|
)
|
|
28
|
-
from typing_extensions import
|
|
32
|
+
from typing_extensions import Self
|
|
29
33
|
|
|
30
34
|
from strawberry.relay.exceptions import NodeIDAnnotationError
|
|
31
35
|
from strawberry.types.base import (
|
strawberry/resolvers.py
CHANGED
strawberry/sanic/views.py
CHANGED
|
@@ -5,11 +5,10 @@ import warnings
|
|
|
5
5
|
from typing import (
|
|
6
6
|
TYPE_CHECKING,
|
|
7
7
|
Any,
|
|
8
|
-
Callable,
|
|
9
8
|
Optional,
|
|
9
|
+
TypeGuard,
|
|
10
10
|
Union,
|
|
11
11
|
)
|
|
12
|
-
from typing_extensions import TypeGuard
|
|
13
12
|
|
|
14
13
|
from lia import HTTPException, SanicHTTPRequestAdapter
|
|
15
14
|
|
|
@@ -24,7 +23,7 @@ from strawberry.http.typevars import (
|
|
|
24
23
|
)
|
|
25
24
|
|
|
26
25
|
if TYPE_CHECKING:
|
|
27
|
-
from collections.abc import AsyncGenerator
|
|
26
|
+
from collections.abc import AsyncGenerator, Callable
|
|
28
27
|
|
|
29
28
|
from strawberry.http import GraphQLHTTPResponse
|
|
30
29
|
from strawberry.http.ides import GraphQL_IDE
|
strawberry/schema/compat.py
CHANGED
|
@@ -11,7 +11,7 @@ from strawberry.types.base import StrawberryType, has_object_definition
|
|
|
11
11
|
|
|
12
12
|
if TYPE_CHECKING:
|
|
13
13
|
from collections.abc import Mapping
|
|
14
|
-
from
|
|
14
|
+
from typing import TypeGuard
|
|
15
15
|
|
|
16
16
|
from strawberry.types.scalar import ScalarDefinition, ScalarWrapper
|
|
17
17
|
|
strawberry/schema/config.py
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from dataclasses import InitVar, dataclass, field
|
|
4
|
-
from typing import
|
|
4
|
+
from typing import TYPE_CHECKING, Any, Optional, TypedDict
|
|
5
5
|
|
|
6
6
|
from strawberry.types.info import Info
|
|
7
7
|
|
|
8
8
|
from .name_converter import NameConverter
|
|
9
9
|
|
|
10
|
+
if TYPE_CHECKING:
|
|
11
|
+
from collections.abc import Callable
|
|
12
|
+
|
|
10
13
|
|
|
11
14
|
class BatchingConfig(TypedDict):
|
|
12
15
|
max_operations: int
|
strawberry/schema/schema.py
CHANGED
|
@@ -2,13 +2,12 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import warnings
|
|
4
4
|
from asyncio import ensure_future
|
|
5
|
-
from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Iterable
|
|
5
|
+
from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable, Iterable
|
|
6
6
|
from functools import cached_property, lru_cache
|
|
7
7
|
from inspect import isawaitable
|
|
8
8
|
from typing import (
|
|
9
9
|
TYPE_CHECKING,
|
|
10
10
|
Any,
|
|
11
|
-
Callable,
|
|
12
11
|
NamedTuple,
|
|
13
12
|
Optional,
|
|
14
13
|
Union,
|
|
@@ -83,7 +82,7 @@ from .exceptions import CannotGetOperationTypeError, InvalidOperationTypeError
|
|
|
83
82
|
|
|
84
83
|
if TYPE_CHECKING:
|
|
85
84
|
from collections.abc import Iterable, Mapping
|
|
86
|
-
from
|
|
85
|
+
from typing import TypeAlias
|
|
87
86
|
|
|
88
87
|
from graphql.language import DocumentNode
|
|
89
88
|
from graphql.pyutils import Path
|
|
@@ -2,11 +2,12 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import dataclasses
|
|
4
4
|
import sys
|
|
5
|
+
import typing
|
|
5
6
|
from functools import partial, reduce
|
|
6
7
|
from typing import (
|
|
7
8
|
TYPE_CHECKING,
|
|
9
|
+
Annotated,
|
|
8
10
|
Any,
|
|
9
|
-
Callable,
|
|
10
11
|
Generic,
|
|
11
12
|
Optional,
|
|
12
13
|
TypeVar,
|
|
@@ -80,7 +81,7 @@ from . import compat
|
|
|
80
81
|
from .types.concrete_type import ConcreteType
|
|
81
82
|
|
|
82
83
|
if TYPE_CHECKING:
|
|
83
|
-
from collections.abc import Awaitable, Mapping
|
|
84
|
+
from collections.abc import Awaitable, Callable, Mapping
|
|
84
85
|
|
|
85
86
|
from graphql import (
|
|
86
87
|
GraphQLInputType,
|
|
@@ -869,6 +870,12 @@ class GraphQLCoreConverter:
|
|
|
869
870
|
if compat.is_graphql_generic(type_):
|
|
870
871
|
raise MissingTypesForGenericError(type_)
|
|
871
872
|
|
|
873
|
+
# to handle lazy unions
|
|
874
|
+
if typing.get_origin(type_) is Annotated:
|
|
875
|
+
args = typing.get_args(type_)
|
|
876
|
+
if len(args) >= 2 and isinstance(args[1], StrawberryUnion):
|
|
877
|
+
type_ = args[1]
|
|
878
|
+
|
|
872
879
|
if isinstance(type_, EnumDefinition): # TODO: Replace with StrawberryEnum
|
|
873
880
|
return self.from_enum(type_)
|
|
874
881
|
if compat.is_input_type(type_): # TODO: Replace with StrawberryInputObject
|
|
@@ -4,8 +4,8 @@ import dataclasses
|
|
|
4
4
|
import keyword
|
|
5
5
|
from collections import defaultdict
|
|
6
6
|
from graphlib import TopologicalSorter
|
|
7
|
-
from typing import TYPE_CHECKING, Union
|
|
8
|
-
from typing_extensions import Protocol
|
|
7
|
+
from typing import TYPE_CHECKING, TypeAlias, Union
|
|
8
|
+
from typing_extensions import Protocol
|
|
9
9
|
|
|
10
10
|
import libcst as cst
|
|
11
11
|
from graphql import (
|
strawberry/schema_directive.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import dataclasses
|
|
2
|
+
from collections.abc import Callable
|
|
2
3
|
from enum import Enum
|
|
3
|
-
from typing import
|
|
4
|
+
from typing import Optional, TypeVar
|
|
4
5
|
from typing_extensions import dataclass_transform
|
|
5
6
|
|
|
6
7
|
from strawberry.types.field import StrawberryField, field
|
strawberry/test/client.py
CHANGED
|
@@ -4,8 +4,8 @@ import json
|
|
|
4
4
|
import warnings
|
|
5
5
|
from abc import ABC, abstractmethod
|
|
6
6
|
from dataclasses import dataclass
|
|
7
|
-
from typing import TYPE_CHECKING, Any, Optional, Union
|
|
8
|
-
from typing_extensions import
|
|
7
|
+
from typing import TYPE_CHECKING, Any, Literal, Optional, Union
|
|
8
|
+
from typing_extensions import TypedDict
|
|
9
9
|
|
|
10
10
|
if TYPE_CHECKING:
|
|
11
11
|
from collections.abc import Coroutine, Mapping
|
strawberry/types/arguments.py
CHANGED
|
@@ -9,8 +9,9 @@ from typing import (
|
|
|
9
9
|
Optional,
|
|
10
10
|
Union,
|
|
11
11
|
cast,
|
|
12
|
+
get_args,
|
|
13
|
+
get_origin,
|
|
12
14
|
)
|
|
13
|
-
from typing_extensions import get_args, get_origin
|
|
14
15
|
|
|
15
16
|
from strawberry.annotation import StrawberryAnnotation
|
|
16
17
|
from strawberry.exceptions import MultipleStrawberryArgumentsError, UnsupportedTypeError
|
strawberry/types/auto.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
from typing import Annotated, Any, Optional, Union, cast
|
|
4
|
-
from typing_extensions import get_args, get_origin
|
|
3
|
+
from typing import Annotated, Any, Optional, Union, cast, get_args, get_origin
|
|
5
4
|
|
|
6
5
|
from strawberry.annotation import StrawberryAnnotation
|
|
7
6
|
from strawberry.types.base import StrawberryType
|
strawberry/types/base.py
CHANGED
|
@@ -5,14 +5,14 @@ from abc import ABC, abstractmethod
|
|
|
5
5
|
from typing import (
|
|
6
6
|
TYPE_CHECKING,
|
|
7
7
|
Any,
|
|
8
|
-
Callable,
|
|
9
8
|
ClassVar,
|
|
9
|
+
Literal,
|
|
10
10
|
Optional,
|
|
11
11
|
TypeVar,
|
|
12
12
|
Union,
|
|
13
13
|
overload,
|
|
14
14
|
)
|
|
15
|
-
from typing_extensions import
|
|
15
|
+
from typing_extensions import Protocol, Self, deprecated
|
|
16
16
|
|
|
17
17
|
from strawberry.utils.deprecations import DEPRECATION_MESSAGES, DeprecatedDescriptor
|
|
18
18
|
from strawberry.utils.inspect import get_specialized_type_var_map
|
|
@@ -20,8 +20,8 @@ from strawberry.utils.typing import is_concrete_generic
|
|
|
20
20
|
from strawberry.utils.typing import is_generic as is_type_generic
|
|
21
21
|
|
|
22
22
|
if TYPE_CHECKING:
|
|
23
|
-
from collections.abc import Mapping, Sequence
|
|
24
|
-
from
|
|
23
|
+
from collections.abc import Callable, Mapping, Sequence
|
|
24
|
+
from typing import TypeGuard
|
|
25
25
|
|
|
26
26
|
from graphql import GraphQLAbstractType, GraphQLResolveInfo
|
|
27
27
|
|
|
@@ -291,7 +291,9 @@ class StrawberryObjectDefinition(StrawberryType):
|
|
|
291
291
|
resolved_type = StrawberryAnnotation(passed_type).resolve()
|
|
292
292
|
resolved_types.append(resolved_type)
|
|
293
293
|
|
|
294
|
-
type_var_map = dict(
|
|
294
|
+
type_var_map = dict(
|
|
295
|
+
zip((param.__name__ for param in params), resolved_types, strict=True)
|
|
296
|
+
)
|
|
295
297
|
|
|
296
298
|
return self.copy_with(type_var_map)
|
|
297
299
|
|
strawberry/types/enum.py
CHANGED
strawberry/types/field.py
CHANGED
|
@@ -4,12 +4,11 @@ import contextlib
|
|
|
4
4
|
import copy
|
|
5
5
|
import dataclasses
|
|
6
6
|
import sys
|
|
7
|
-
from collections.abc import Awaitable, Coroutine, Mapping, Sequence
|
|
7
|
+
from collections.abc import Awaitable, Callable, Coroutine, Mapping, Sequence
|
|
8
8
|
from functools import cached_property
|
|
9
9
|
from typing import (
|
|
10
10
|
TYPE_CHECKING,
|
|
11
11
|
Any,
|
|
12
|
-
Callable,
|
|
13
12
|
Optional,
|
|
14
13
|
TypeVar,
|
|
15
14
|
Union,
|
|
@@ -29,7 +28,8 @@ from .fields.resolver import StrawberryResolver
|
|
|
29
28
|
|
|
30
29
|
if TYPE_CHECKING:
|
|
31
30
|
import builtins
|
|
32
|
-
from
|
|
31
|
+
from typing import Literal
|
|
32
|
+
from typing_extensions import Self
|
|
33
33
|
|
|
34
34
|
from strawberry.extensions.field_extension import FieldExtension
|
|
35
35
|
from strawberry.permission import BasePermission
|
|
@@ -92,11 +92,9 @@ class StrawberryField(dataclasses.Field):
|
|
|
92
92
|
# basic fields are fields with no provided resolver
|
|
93
93
|
is_basic_field = not base_resolver
|
|
94
94
|
|
|
95
|
-
kwargs: Any = {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if sys.version_info >= (3, 10):
|
|
99
|
-
kwargs["kw_only"] = dataclasses.MISSING
|
|
95
|
+
kwargs: Any = {
|
|
96
|
+
"kw_only": True,
|
|
97
|
+
}
|
|
100
98
|
|
|
101
99
|
# doc was added to python 3.14 and it is required
|
|
102
100
|
if sys.version_info >= (3, 14):
|
|
@@ -10,15 +10,15 @@ from typing import (
|
|
|
10
10
|
TYPE_CHECKING,
|
|
11
11
|
Annotated,
|
|
12
12
|
Any,
|
|
13
|
-
Callable,
|
|
14
13
|
Generic,
|
|
15
14
|
NamedTuple,
|
|
16
15
|
Optional,
|
|
17
16
|
TypeVar,
|
|
18
17
|
Union,
|
|
19
18
|
cast,
|
|
19
|
+
get_origin,
|
|
20
20
|
)
|
|
21
|
-
from typing_extensions import Protocol
|
|
21
|
+
from typing_extensions import Protocol
|
|
22
22
|
|
|
23
23
|
from strawberry.annotation import StrawberryAnnotation
|
|
24
24
|
from strawberry.exceptions import (
|
|
@@ -33,7 +33,7 @@ from strawberry.utils.typing import type_has_annotation
|
|
|
33
33
|
|
|
34
34
|
if TYPE_CHECKING:
|
|
35
35
|
import builtins
|
|
36
|
-
from collections.abc import Mapping
|
|
36
|
+
from collections.abc import Callable, Mapping
|
|
37
37
|
|
|
38
38
|
|
|
39
39
|
class Parameter(inspect.Parameter):
|
strawberry/types/maybe.py
CHANGED
strawberry/types/mutation.py
CHANGED
|
@@ -4,12 +4,11 @@ import dataclasses
|
|
|
4
4
|
from typing import (
|
|
5
5
|
TYPE_CHECKING,
|
|
6
6
|
Any,
|
|
7
|
-
|
|
7
|
+
Literal,
|
|
8
8
|
Optional,
|
|
9
9
|
Union,
|
|
10
10
|
overload,
|
|
11
11
|
)
|
|
12
|
-
from typing_extensions import Literal
|
|
13
12
|
|
|
14
13
|
from strawberry.types.field import (
|
|
15
14
|
_RESOLVER_TYPE,
|
|
@@ -21,8 +20,8 @@ from strawberry.types.field import (
|
|
|
21
20
|
)
|
|
22
21
|
|
|
23
22
|
if TYPE_CHECKING:
|
|
24
|
-
from collections.abc import Mapping, Sequence
|
|
25
|
-
from
|
|
23
|
+
from collections.abc import Callable, Mapping, Sequence
|
|
24
|
+
from typing import Literal
|
|
26
25
|
|
|
27
26
|
from strawberry.extensions.field_extension import FieldExtension
|
|
28
27
|
from strawberry.permission import BasePermission
|
strawberry/types/object_type.py
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import builtins
|
|
2
2
|
import dataclasses
|
|
3
3
|
import inspect
|
|
4
|
-
import sys
|
|
5
4
|
import types
|
|
6
|
-
from collections.abc import Sequence
|
|
5
|
+
from collections.abc import Callable, Sequence
|
|
7
6
|
from typing import (
|
|
8
7
|
Any,
|
|
9
|
-
Callable,
|
|
10
8
|
Optional,
|
|
11
9
|
TypeVar,
|
|
12
10
|
Union,
|
|
@@ -105,24 +103,7 @@ def _wrap_dataclass(cls: builtins.type[T]) -> builtins.type[T]:
|
|
|
105
103
|
"""Wrap a strawberry.type class with a dataclass and check for any issues before doing so."""
|
|
106
104
|
# Ensure all Fields have been properly type-annotated
|
|
107
105
|
_check_field_annotations(cls)
|
|
108
|
-
|
|
109
|
-
dclass_kwargs: dict[str, bool] = {}
|
|
110
|
-
|
|
111
|
-
# Python 3.10 introduces the kw_only param. If we're on an older version
|
|
112
|
-
# then generate our own custom init function
|
|
113
|
-
if sys.version_info >= (3, 10):
|
|
114
|
-
dclass_kwargs["kw_only"] = True
|
|
115
|
-
else:
|
|
116
|
-
dclass_kwargs["init"] = False
|
|
117
|
-
|
|
118
|
-
dclass = dataclasses.dataclass(cls, **dclass_kwargs)
|
|
119
|
-
|
|
120
|
-
if sys.version_info < (3, 10):
|
|
121
|
-
from strawberry.utils.dataclasses import add_custom_init_fn
|
|
122
|
-
|
|
123
|
-
add_custom_init_fn(dclass)
|
|
124
|
-
|
|
125
|
-
return dclass
|
|
106
|
+
return dataclasses.dataclass(kw_only=True)(cls)
|
|
126
107
|
|
|
127
108
|
|
|
128
109
|
def _inject_default_for_maybe_annotations(
|
strawberry/types/scalar.py
CHANGED
|
@@ -5,7 +5,6 @@ from dataclasses import dataclass
|
|
|
5
5
|
from typing import (
|
|
6
6
|
TYPE_CHECKING,
|
|
7
7
|
Any,
|
|
8
|
-
Callable,
|
|
9
8
|
NewType,
|
|
10
9
|
Optional,
|
|
11
10
|
TypeVar,
|
|
@@ -18,16 +17,12 @@ from strawberry.types.base import StrawberryType
|
|
|
18
17
|
from strawberry.utils.str_converters import to_camel_case
|
|
19
18
|
|
|
20
19
|
if TYPE_CHECKING:
|
|
21
|
-
from collections.abc import Iterable, Mapping
|
|
20
|
+
from collections.abc import Callable, Iterable, Mapping
|
|
22
21
|
|
|
23
22
|
from graphql import GraphQLScalarType
|
|
24
23
|
|
|
25
24
|
|
|
26
|
-
|
|
27
|
-
if sys.version_info >= (3, 10):
|
|
28
|
-
_T = TypeVar("_T", bound=Union[type, NewType])
|
|
29
|
-
else:
|
|
30
|
-
_T = TypeVar("_T", bound=type)
|
|
25
|
+
_T = TypeVar("_T", bound=Union[type, NewType])
|
|
31
26
|
|
|
32
27
|
|
|
33
28
|
def identity(x: _T) -> _T:
|
strawberry/types/union.py
CHANGED
strawberry/utils/aio.py
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import sys
|
|
2
|
-
from collections.abc import
|
|
2
|
+
from collections.abc import (
|
|
3
|
+
AsyncGenerator,
|
|
4
|
+
AsyncIterable,
|
|
5
|
+
AsyncIterator,
|
|
6
|
+
Awaitable,
|
|
7
|
+
Callable,
|
|
8
|
+
)
|
|
3
9
|
from contextlib import asynccontextmanager, suppress
|
|
4
10
|
from typing import (
|
|
5
11
|
Any,
|
|
6
|
-
Callable,
|
|
7
12
|
Optional,
|
|
8
13
|
TypeVar,
|
|
9
14
|
Union,
|
strawberry/utils/inspect.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import inspect
|
|
3
|
+
from collections.abc import Callable
|
|
3
4
|
from functools import lru_cache
|
|
4
5
|
from typing import (
|
|
5
6
|
Any,
|
|
6
|
-
Callable,
|
|
7
7
|
Generic,
|
|
8
8
|
Optional,
|
|
9
9
|
Protocol,
|
|
@@ -99,7 +99,7 @@ def get_specialized_type_var_map(cls: type) -> Optional[dict[str, type]]:
|
|
|
99
99
|
if (type_params := getattr(origin, "__parameters__", None)) is not None:
|
|
100
100
|
args = get_args(tp)
|
|
101
101
|
if args:
|
|
102
|
-
for type_param, arg in zip(type_params, args):
|
|
102
|
+
for type_param, arg in zip(type_params, args, strict=True):
|
|
103
103
|
if type_param not in param_args:
|
|
104
104
|
param_args[type_param] = arg
|
|
105
105
|
else:
|