strawberry-graphql 0.255.0__py3-none-any.whl → 0.256.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.
Files changed (155) hide show
  1. strawberry/__init__.py +9 -9
  2. strawberry/aiohttp/test/client.py +10 -8
  3. strawberry/aiohttp/views.py +5 -7
  4. strawberry/annotation.py +12 -15
  5. strawberry/asgi/__init__.py +3 -6
  6. strawberry/asgi/test/client.py +9 -8
  7. strawberry/chalice/views.py +4 -2
  8. strawberry/channels/__init__.py +1 -1
  9. strawberry/channels/handlers/base.py +3 -7
  10. strawberry/channels/handlers/http_handler.py +5 -6
  11. strawberry/channels/handlers/ws_handler.py +3 -4
  12. strawberry/channels/testing.py +5 -9
  13. strawberry/cli/commands/codegen.py +9 -9
  14. strawberry/cli/commands/upgrade/__init__.py +2 -3
  15. strawberry/cli/commands/upgrade/_run_codemod.py +7 -5
  16. strawberry/codegen/exceptions.py +2 -2
  17. strawberry/codegen/plugins/print_operation.py +6 -6
  18. strawberry/codegen/plugins/python.py +6 -6
  19. strawberry/codegen/plugins/typescript.py +3 -3
  20. strawberry/codegen/query_codegen.py +29 -34
  21. strawberry/codegen/types.py +35 -34
  22. strawberry/codemods/annotated_unions.py +5 -2
  23. strawberry/dataloader.py +13 -20
  24. strawberry/directive.py +12 -5
  25. strawberry/django/test/client.py +4 -4
  26. strawberry/django/views.py +4 -5
  27. strawberry/exceptions/__init__.py +24 -24
  28. strawberry/exceptions/conflicting_arguments.py +2 -2
  29. strawberry/exceptions/duplicated_type_name.py +3 -3
  30. strawberry/exceptions/handler.py +7 -7
  31. strawberry/exceptions/invalid_union_type.py +2 -2
  32. strawberry/exceptions/missing_arguments_annotations.py +2 -2
  33. strawberry/exceptions/missing_field_annotation.py +2 -2
  34. strawberry/exceptions/object_is_not_an_enum.py +2 -2
  35. strawberry/exceptions/private_strawberry_field.py +2 -2
  36. strawberry/exceptions/syntax.py +4 -4
  37. strawberry/exceptions/utils/source_finder.py +7 -6
  38. strawberry/experimental/pydantic/__init__.py +3 -3
  39. strawberry/experimental/pydantic/_compat.py +14 -14
  40. strawberry/experimental/pydantic/conversion.py +2 -2
  41. strawberry/experimental/pydantic/conversion_types.py +3 -3
  42. strawberry/experimental/pydantic/error_type.py +18 -16
  43. strawberry/experimental/pydantic/exceptions.py +5 -5
  44. strawberry/experimental/pydantic/fields.py +2 -13
  45. strawberry/experimental/pydantic/object_type.py +20 -22
  46. strawberry/experimental/pydantic/utils.py +6 -10
  47. strawberry/ext/dataclasses/dataclasses.py +3 -3
  48. strawberry/ext/mypy_plugin.py +6 -9
  49. strawberry/extensions/__init__.py +7 -8
  50. strawberry/extensions/add_validation_rules.py +5 -3
  51. strawberry/extensions/base_extension.py +4 -4
  52. strawberry/extensions/context.py +15 -14
  53. strawberry/extensions/directives.py +2 -2
  54. strawberry/extensions/disable_validation.py +1 -1
  55. strawberry/extensions/field_extension.py +2 -1
  56. strawberry/extensions/mask_errors.py +3 -2
  57. strawberry/extensions/max_aliases.py +2 -2
  58. strawberry/extensions/max_tokens.py +1 -1
  59. strawberry/extensions/parser_cache.py +2 -1
  60. strawberry/extensions/pyinstrument.py +4 -1
  61. strawberry/extensions/query_depth_limiter.py +13 -13
  62. strawberry/extensions/runner.py +7 -7
  63. strawberry/extensions/tracing/apollo.py +11 -9
  64. strawberry/extensions/tracing/datadog.py +3 -1
  65. strawberry/extensions/tracing/opentelemetry.py +7 -10
  66. strawberry/extensions/utils.py +3 -3
  67. strawberry/extensions/validation_cache.py +2 -1
  68. strawberry/fastapi/context.py +3 -3
  69. strawberry/fastapi/router.py +9 -14
  70. strawberry/federation/__init__.py +4 -4
  71. strawberry/federation/argument.py +2 -1
  72. strawberry/federation/enum.py +8 -8
  73. strawberry/federation/field.py +25 -28
  74. strawberry/federation/object_type.py +24 -26
  75. strawberry/federation/scalar.py +7 -8
  76. strawberry/federation/schema.py +30 -36
  77. strawberry/federation/schema_directive.py +5 -5
  78. strawberry/federation/schema_directives.py +14 -14
  79. strawberry/federation/union.py +3 -2
  80. strawberry/field_extensions/input_mutation.py +1 -2
  81. strawberry/file_uploads/utils.py +4 -3
  82. strawberry/flask/views.py +3 -2
  83. strawberry/http/__init__.py +6 -6
  84. strawberry/http/async_base_view.py +9 -14
  85. strawberry/http/base.py +5 -4
  86. strawberry/http/ides.py +1 -1
  87. strawberry/http/parse_content_type.py +1 -2
  88. strawberry/http/sync_base_view.py +3 -5
  89. strawberry/http/temporal_response.py +1 -2
  90. strawberry/http/types.py +3 -2
  91. strawberry/litestar/controller.py +8 -14
  92. strawberry/parent.py +1 -2
  93. strawberry/permission.py +6 -8
  94. strawberry/printer/ast_from_value.py +2 -1
  95. strawberry/printer/printer.py +50 -30
  96. strawberry/quart/views.py +3 -3
  97. strawberry/relay/exceptions.py +4 -4
  98. strawberry/relay/fields.py +22 -24
  99. strawberry/relay/types.py +29 -27
  100. strawberry/relay/utils.py +4 -4
  101. strawberry/sanic/utils.py +4 -4
  102. strawberry/sanic/views.py +5 -7
  103. strawberry/scalars.py +2 -2
  104. strawberry/schema/base.py +16 -11
  105. strawberry/schema/compat.py +4 -4
  106. strawberry/schema/execute.py +6 -10
  107. strawberry/schema/name_converter.py +3 -3
  108. strawberry/schema/schema.py +37 -25
  109. strawberry/schema/schema_converter.py +22 -24
  110. strawberry/schema/subscribe.py +4 -3
  111. strawberry/schema/types/base_scalars.py +1 -1
  112. strawberry/schema/types/concrete_type.py +2 -2
  113. strawberry/schema/types/scalar.py +3 -4
  114. strawberry/schema_codegen/__init__.py +4 -4
  115. strawberry/schema_directive.py +8 -8
  116. strawberry/subscriptions/protocols/graphql_transport_ws/handlers.py +8 -9
  117. strawberry/subscriptions/protocols/graphql_transport_ws/types.py +16 -16
  118. strawberry/subscriptions/protocols/graphql_ws/handlers.py +6 -5
  119. strawberry/subscriptions/protocols/graphql_ws/types.py +13 -13
  120. strawberry/test/__init__.py +1 -1
  121. strawberry/test/client.py +21 -19
  122. strawberry/tools/create_type.py +4 -3
  123. strawberry/tools/merge_types.py +1 -2
  124. strawberry/types/__init__.py +1 -1
  125. strawberry/types/arguments.py +10 -12
  126. strawberry/types/auto.py +2 -2
  127. strawberry/types/base.py +17 -21
  128. strawberry/types/enum.py +3 -5
  129. strawberry/types/execution.py +8 -12
  130. strawberry/types/field.py +26 -31
  131. strawberry/types/fields/resolver.py +15 -17
  132. strawberry/types/graphql.py +2 -2
  133. strawberry/types/info.py +5 -9
  134. strawberry/types/lazy_type.py +3 -5
  135. strawberry/types/mutation.py +25 -28
  136. strawberry/types/nodes.py +11 -9
  137. strawberry/types/object_type.py +14 -16
  138. strawberry/types/private.py +1 -2
  139. strawberry/types/scalar.py +2 -2
  140. strawberry/types/type_resolver.py +5 -5
  141. strawberry/types/union.py +8 -11
  142. strawberry/types/unset.py +3 -3
  143. strawberry/utils/aio.py +3 -8
  144. strawberry/utils/await_maybe.py +3 -2
  145. strawberry/utils/debug.py +2 -2
  146. strawberry/utils/deprecations.py +2 -2
  147. strawberry/utils/inspect.py +3 -5
  148. strawberry/utils/str_converters.py +1 -1
  149. strawberry/utils/typing.py +38 -67
  150. {strawberry_graphql-0.255.0.dist-info → strawberry_graphql-0.256.0.dist-info}/METADATA +3 -6
  151. strawberry_graphql-0.256.0.dist-info/RECORD +236 -0
  152. strawberry_graphql-0.255.0.dist-info/RECORD +0 -236
  153. {strawberry_graphql-0.255.0.dist-info → strawberry_graphql-0.256.0.dist-info}/LICENSE +0 -0
  154. {strawberry_graphql-0.255.0.dist-info → strawberry_graphql-0.256.0.dist-info}/WHEEL +0 -0
  155. {strawberry_graphql-0.255.0.dist-info → strawberry_graphql-0.256.0.dist-info}/entry_points.txt +0 -0
@@ -1,5 +1,6 @@
1
1
  import types
2
- from typing import List, Optional, Sequence, Type
2
+ from collections.abc import Sequence
3
+ from typing import Optional
3
4
 
4
5
  import strawberry
5
6
  from strawberry.types.field import StrawberryField
@@ -7,13 +8,13 @@ from strawberry.types.field import StrawberryField
7
8
 
8
9
  def create_type(
9
10
  name: str,
10
- fields: List[StrawberryField],
11
+ fields: list[StrawberryField],
11
12
  is_input: bool = False,
12
13
  is_interface: bool = False,
13
14
  description: Optional[str] = None,
14
15
  directives: Optional[Sequence[object]] = (),
15
16
  extend: bool = False,
16
- ) -> Type:
17
+ ) -> type:
17
18
  """Create a Strawberry type from a list of StrawberryFields.
18
19
 
19
20
  Args:
@@ -1,13 +1,12 @@
1
1
  import warnings
2
2
  from collections import Counter
3
3
  from itertools import chain
4
- from typing import Tuple
5
4
 
6
5
  import strawberry
7
6
  from strawberry.types.base import has_object_definition
8
7
 
9
8
 
10
- def merge_types(name: str, types: Tuple[type, ...]) -> type:
9
+ def merge_types(name: str, types: tuple[type, ...]) -> type:
11
10
  """Merge multiple Strawberry types into one.
12
11
 
13
12
  For example, given two queries `A` and `B`, one can merge them into a
@@ -5,9 +5,9 @@ from .info import Info
5
5
  __all__ = [
6
6
  "ExecutionContext",
7
7
  "ExecutionResult",
8
- "SubscriptionExecutionResult",
9
8
  "Info",
10
9
  "Info",
10
+ "SubscriptionExecutionResult",
11
11
  "get_object_definition",
12
12
  "has_object_definition",
13
13
  ]
@@ -2,18 +2,16 @@ from __future__ import annotations
2
2
 
3
3
  import inspect
4
4
  import warnings
5
+ from collections.abc import Iterable, Mapping
5
6
  from typing import (
6
7
  TYPE_CHECKING,
8
+ Annotated,
7
9
  Any,
8
- Dict,
9
- Iterable,
10
- List,
11
- Mapping,
12
10
  Optional,
13
11
  Union,
14
12
  cast,
15
13
  )
16
- from typing_extensions import Annotated, get_args, get_origin
14
+ from typing_extensions import get_args, get_origin
17
15
 
18
16
  from strawberry.annotation import StrawberryAnnotation
19
17
  from strawberry.exceptions import MultipleStrawberryArgumentsError, UnsupportedTypeError
@@ -34,7 +32,7 @@ if TYPE_CHECKING:
34
32
  from strawberry.types.scalar import ScalarDefinition, ScalarWrapper
35
33
 
36
34
 
37
- DEPRECATED_NAMES: Dict[str, str] = {
35
+ DEPRECATED_NAMES: dict[str, str] = {
38
36
  "UNSET": (
39
37
  "importing `UNSET` from `strawberry.arguments` is deprecated, "
40
38
  "import instead from `strawberry` or from `strawberry.types.unset`"
@@ -140,7 +138,7 @@ class StrawberryArgument:
140
138
  def convert_argument(
141
139
  value: object,
142
140
  type_: Union[StrawberryType, type],
143
- scalar_registry: Dict[object, Union[ScalarWrapper, ScalarDefinition]],
141
+ scalar_registry: dict[object, Union[ScalarWrapper, ScalarDefinition]],
144
142
  config: StrawberryConfig,
145
143
  ) -> object:
146
144
  # TODO: move this somewhere else and make it first class
@@ -197,11 +195,11 @@ def convert_argument(
197
195
 
198
196
 
199
197
  def convert_arguments(
200
- value: Dict[str, Any],
201
- arguments: List[StrawberryArgument],
202
- scalar_registry: Dict[object, Union[ScalarWrapper, ScalarDefinition]],
198
+ value: dict[str, Any],
199
+ arguments: list[StrawberryArgument],
200
+ scalar_registry: dict[object, Union[ScalarWrapper, ScalarDefinition]],
203
201
  config: StrawberryConfig,
204
- ) -> Dict[str, Any]:
202
+ ) -> dict[str, Any]:
205
203
  """Converts a nested dictionary to a dictionary of actual types.
206
204
 
207
205
  It deals with conversion of input types to proper dataclasses and
@@ -283,9 +281,9 @@ def __getattr__(name: str) -> Any:
283
281
 
284
282
  # TODO: check exports
285
283
  __all__ = [ # noqa: F822
284
+ "UNSET", # for backwards compatibility # type: ignore
286
285
  "StrawberryArgument",
287
286
  "StrawberryArgumentAnnotation",
288
- "UNSET", # for backwards compatibility # type: ignore
289
287
  "argument",
290
288
  "is_unset", # for backwards compatibility # type: ignore
291
289
  ]
strawberry/types/auto.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Any, Optional, Union, cast
4
- from typing_extensions import Annotated, get_args, get_origin
3
+ from typing import Annotated, Any, Optional, Union, cast
4
+ from typing_extensions import get_args, get_origin
5
5
 
6
6
  from strawberry.annotation import StrawberryAnnotation
7
7
  from strawberry.types.base import StrawberryType
strawberry/types/base.py CHANGED
@@ -7,12 +7,7 @@ from typing import (
7
7
  Any,
8
8
  Callable,
9
9
  ClassVar,
10
- Dict,
11
- List,
12
- Mapping,
13
10
  Optional,
14
- Sequence,
15
- Type,
16
11
  TypeVar,
17
12
  Union,
18
13
  overload,
@@ -25,6 +20,7 @@ from strawberry.utils.typing import is_concrete_generic
25
20
  from strawberry.utils.typing import is_generic as is_type_generic
26
21
 
27
22
  if TYPE_CHECKING:
23
+ from collections.abc import Mapping, Sequence
28
24
  from typing_extensions import TypeGuard
29
25
 
30
26
  from graphql import GraphQLAbstractType, GraphQLResolveInfo
@@ -44,7 +40,7 @@ class StrawberryType(ABC):
44
40
  """
45
41
 
46
42
  @property
47
- def type_params(self) -> List[TypeVar]:
43
+ def type_params(self) -> list[TypeVar]:
48
44
  return []
49
45
 
50
46
  @property
@@ -55,9 +51,9 @@ class StrawberryType(ABC):
55
51
  def copy_with(
56
52
  self,
57
53
  type_var_map: Mapping[
58
- str, Union[StrawberryType, Type[WithStrawberryObjectDefinition]]
54
+ str, Union[StrawberryType, type[WithStrawberryObjectDefinition]]
59
55
  ],
60
- ) -> Union[StrawberryType, Type[WithStrawberryObjectDefinition]]:
56
+ ) -> Union[StrawberryType, type[WithStrawberryObjectDefinition]]:
61
57
  raise NotImplementedError()
62
58
 
63
59
  @property
@@ -93,7 +89,7 @@ class StrawberryType(ABC):
93
89
 
94
90
  class StrawberryContainer(StrawberryType):
95
91
  def __init__(
96
- self, of_type: Union[StrawberryType, Type[WithStrawberryObjectDefinition], type]
92
+ self, of_type: Union[StrawberryType, type[WithStrawberryObjectDefinition], type]
97
93
  ) -> None:
98
94
  self.of_type = of_type
99
95
 
@@ -110,7 +106,7 @@ class StrawberryContainer(StrawberryType):
110
106
  return super().__eq__(other)
111
107
 
112
108
  @property
113
- def type_params(self) -> List[TypeVar]:
109
+ def type_params(self) -> list[TypeVar]:
114
110
  if has_object_definition(self.of_type):
115
111
  parameters = getattr(self.of_type, "__parameters__", None)
116
112
 
@@ -125,7 +121,7 @@ class StrawberryContainer(StrawberryType):
125
121
  def copy_with(
126
122
  self,
127
123
  type_var_map: Mapping[
128
- str, Union[StrawberryType, Type[WithStrawberryObjectDefinition]]
124
+ str, Union[StrawberryType, type[WithStrawberryObjectDefinition]]
129
125
  ],
130
126
  ) -> Self:
131
127
  of_type_copy = self.of_type
@@ -180,7 +176,7 @@ class StrawberryTypeVar(StrawberryType):
180
176
  return self.type_var == type_var
181
177
 
182
178
  @property
183
- def type_params(self) -> List[TypeVar]:
179
+ def type_params(self) -> list[TypeVar]:
184
180
  return [self.type_var]
185
181
 
186
182
  def __eq__(self, other: object) -> bool:
@@ -201,7 +197,7 @@ class WithStrawberryObjectDefinition(Protocol):
201
197
 
202
198
  def has_object_definition(
203
199
  obj: Any,
204
- ) -> TypeGuard[Type[WithStrawberryObjectDefinition]]:
200
+ ) -> TypeGuard[type[WithStrawberryObjectDefinition]]:
205
201
  if hasattr(obj, "__strawberry_definition__"):
206
202
  return True
207
203
  # TODO: Generics remove dunder members here, so we inject it here.
@@ -254,9 +250,9 @@ class StrawberryObjectDefinition(StrawberryType):
254
250
  name: str
255
251
  is_input: bool
256
252
  is_interface: bool
257
- origin: Type[Any]
253
+ origin: type[Any]
258
254
  description: Optional[str]
259
- interfaces: List[StrawberryObjectDefinition]
255
+ interfaces: list[StrawberryObjectDefinition]
260
256
  extend: bool
261
257
  directives: Optional[Sequence[object]]
262
258
  is_type_of: Optional[Callable[[Any, GraphQLResolveInfo], bool]]
@@ -264,7 +260,7 @@ class StrawberryObjectDefinition(StrawberryType):
264
260
  Callable[[Any, GraphQLResolveInfo, GraphQLAbstractType], str]
265
261
  ]
266
262
 
267
- fields: List[StrawberryField]
263
+ fields: list[StrawberryField]
268
264
 
269
265
  concrete_of: Optional[StrawberryObjectDefinition] = None
270
266
  """Concrete implementations of Generic TypeDefinitions fill this in"""
@@ -296,7 +292,7 @@ class StrawberryObjectDefinition(StrawberryType):
296
292
 
297
293
  def copy_with(
298
294
  self, type_var_map: Mapping[str, Union[StrawberryType, type]]
299
- ) -> Type[WithStrawberryObjectDefinition]:
295
+ ) -> type[WithStrawberryObjectDefinition]:
300
296
  fields = [field.copy_with(type_var_map) for field in self.fields]
301
297
 
302
298
  new_type_definition = StrawberryObjectDefinition(
@@ -353,7 +349,7 @@ class StrawberryObjectDefinition(StrawberryType):
353
349
  )
354
350
 
355
351
  @property
356
- def specialized_type_var_map(self) -> Optional[Dict[str, type]]:
352
+ def specialized_type_var_map(self) -> Optional[dict[str, type]]:
357
353
  return get_specialized_type_var_map(self.origin)
358
354
 
359
355
  @property
@@ -361,14 +357,14 @@ class StrawberryObjectDefinition(StrawberryType):
361
357
  return not self.is_input and not self.is_interface
362
358
 
363
359
  @property
364
- def type_params(self) -> List[TypeVar]:
365
- type_params: List[TypeVar] = []
360
+ def type_params(self) -> list[TypeVar]:
361
+ type_params: list[TypeVar] = []
366
362
  for field in self.fields:
367
363
  type_params.extend(field.type_params)
368
364
 
369
365
  return type_params
370
366
 
371
- def is_implemented_by(self, root: Type[WithStrawberryObjectDefinition]) -> bool:
367
+ def is_implemented_by(self, root: type[WithStrawberryObjectDefinition]) -> bool:
372
368
  # TODO: Support dicts
373
369
  if isinstance(root, dict):
374
370
  raise NotImplementedError
strawberry/types/enum.py CHANGED
@@ -1,11 +1,9 @@
1
1
  import dataclasses
2
+ from collections.abc import Iterable, Mapping
2
3
  from enum import EnumMeta
3
4
  from typing import (
4
5
  Any,
5
6
  Callable,
6
- Iterable,
7
- List,
8
- Mapping,
9
7
  Optional,
10
8
  TypeVar,
11
9
  Union,
@@ -29,7 +27,7 @@ class EnumValue:
29
27
  class EnumDefinition(StrawberryType):
30
28
  wrapped_cls: EnumMeta
31
29
  name: str
32
- values: List[EnumValue]
30
+ values: list[EnumValue]
33
31
  description: Optional[str]
34
32
  directives: Iterable[object] = ()
35
33
 
@@ -228,4 +226,4 @@ def enum(
228
226
  return wrap(cls)
229
227
 
230
228
 
231
- __all__ = ["EnumValue", "EnumDefinition", "EnumValueDefinition", "enum", "enum_value"]
229
+ __all__ = ["EnumDefinition", "EnumValue", "EnumValueDefinition", "enum", "enum_value"]
@@ -4,12 +4,7 @@ import dataclasses
4
4
  from typing import (
5
5
  TYPE_CHECKING,
6
6
  Any,
7
- Dict,
8
- Iterable,
9
- List,
10
7
  Optional,
11
- Tuple,
12
- Type,
13
8
  runtime_checkable,
14
9
  )
15
10
  from typing_extensions import Protocol, TypedDict
@@ -19,6 +14,7 @@ from graphql import specified_rules
19
14
  from strawberry.utils.operation import get_first_operation, get_operation_type
20
15
 
21
16
  if TYPE_CHECKING:
17
+ from collections.abc import Iterable
22
18
  from typing_extensions import NotRequired
23
19
 
24
20
  from graphql import ASTValidationRule
@@ -37,12 +33,12 @@ class ExecutionContext:
37
33
  schema: Schema
38
34
  allowed_operations: Iterable[OperationType]
39
35
  context: Any = None
40
- variables: Optional[Dict[str, Any]] = None
36
+ variables: Optional[dict[str, Any]] = None
41
37
  parse_options: ParseOptions = dataclasses.field(
42
38
  default_factory=lambda: ParseOptions()
43
39
  )
44
40
  root_value: Optional[Any] = None
45
- validation_rules: Tuple[Type[ASTValidationRule], ...] = dataclasses.field(
41
+ validation_rules: tuple[type[ASTValidationRule], ...] = dataclasses.field(
46
42
  default_factory=lambda: tuple(specified_rules)
47
43
  )
48
44
 
@@ -52,9 +48,9 @@ class ExecutionContext:
52
48
  # Values that get populated during the GraphQL execution so that they can be
53
49
  # accessed by extensions
54
50
  graphql_document: Optional[DocumentNode] = None
55
- errors: Optional[List[GraphQLError]] = None
51
+ errors: Optional[list[GraphQLError]] = None
56
52
  result: Optional[GraphQLExecutionResult] = None
57
- extensions_results: Dict[str, Any] = dataclasses.field(default_factory=dict)
53
+ extensions_results: dict[str, Any] = dataclasses.field(default_factory=dict)
58
54
 
59
55
  def __post_init__(self, provided_operation_name: str | None) -> None:
60
56
  self._provided_operation_name = provided_operation_name
@@ -91,9 +87,9 @@ class ExecutionContext:
91
87
 
92
88
  @dataclasses.dataclass
93
89
  class ExecutionResult:
94
- data: Optional[Dict[str, Any]]
95
- errors: Optional[List[GraphQLError]]
96
- extensions: Optional[Dict[str, Any]] = None
90
+ data: Optional[dict[str, Any]]
91
+ errors: Optional[list[GraphQLError]]
92
+ extensions: Optional[dict[str, Any]] = None
97
93
 
98
94
 
99
95
  @dataclasses.dataclass
strawberry/types/field.py CHANGED
@@ -4,18 +4,13 @@ import contextlib
4
4
  import copy
5
5
  import dataclasses
6
6
  import sys
7
+ from collections.abc import Awaitable, Coroutine, Mapping, Sequence
7
8
  from functools import cached_property
8
9
  from typing import (
9
10
  TYPE_CHECKING,
10
11
  Any,
11
- Awaitable,
12
12
  Callable,
13
- Coroutine,
14
- List,
15
- Mapping,
16
13
  Optional,
17
- Sequence,
18
- Type,
19
14
  TypeVar,
20
15
  Union,
21
16
  cast,
@@ -83,17 +78,17 @@ class StrawberryField(dataclasses.Field):
83
78
  python_name: Optional[str] = None,
84
79
  graphql_name: Optional[str] = None,
85
80
  type_annotation: Optional[StrawberryAnnotation] = None,
86
- origin: Optional[Union[Type, Callable, staticmethod, classmethod]] = None,
81
+ origin: Optional[Union[type, Callable, staticmethod, classmethod]] = None,
87
82
  is_subscription: bool = False,
88
83
  description: Optional[str] = None,
89
84
  base_resolver: Optional[StrawberryResolver] = None,
90
- permission_classes: List[Type[BasePermission]] = (), # type: ignore
85
+ permission_classes: list[type[BasePermission]] = (), # type: ignore
91
86
  default: object = dataclasses.MISSING,
92
87
  default_factory: Union[Callable[[], Any], object] = dataclasses.MISSING,
93
88
  metadata: Optional[Mapping[Any, Any]] = None,
94
89
  deprecation_reason: Optional[str] = None,
95
90
  directives: Sequence[object] = (),
96
- extensions: List[FieldExtension] = (), # type: ignore
91
+ extensions: list[FieldExtension] = (), # type: ignore
97
92
  ) -> None:
98
93
  # basic fields are fields with no provided resolver
99
94
  is_basic_field = not base_resolver
@@ -124,7 +119,7 @@ class StrawberryField(dataclasses.Field):
124
119
  self.description: Optional[str] = description
125
120
  self.origin = origin
126
121
 
127
- self._arguments: Optional[List[StrawberryArgument]] = None
122
+ self._arguments: Optional[list[StrawberryArgument]] = None
128
123
  self._base_resolver: Optional[StrawberryResolver] = None
129
124
  if base_resolver is not None:
130
125
  self.base_resolver = base_resolver
@@ -142,9 +137,9 @@ class StrawberryField(dataclasses.Field):
142
137
 
143
138
  self.is_subscription = is_subscription
144
139
 
145
- self.permission_classes: List[Type[BasePermission]] = list(permission_classes)
140
+ self.permission_classes: list[type[BasePermission]] = list(permission_classes)
146
141
  self.directives = list(directives)
147
- self.extensions: List[FieldExtension] = list(extensions)
142
+ self.extensions: list[FieldExtension] = list(extensions)
148
143
 
149
144
  # Automatically add the permissions extension
150
145
  if len(self.permission_classes):
@@ -213,7 +208,7 @@ class StrawberryField(dataclasses.Field):
213
208
  return self
214
209
 
215
210
  def get_result(
216
- self, source: Any, info: Optional[Info], args: List[Any], kwargs: Any
211
+ self, source: Any, info: Optional[Info], args: list[Any], kwargs: Any
217
212
  ) -> Union[Awaitable[Any], Any]:
218
213
  """Calls the resolver defined for the StrawberryField.
219
214
 
@@ -238,14 +233,14 @@ class StrawberryField(dataclasses.Field):
238
233
  return not self.base_resolver and not self.extensions
239
234
 
240
235
  @property
241
- def arguments(self) -> List[StrawberryArgument]:
236
+ def arguments(self) -> list[StrawberryArgument]:
242
237
  if self._arguments is None:
243
238
  self._arguments = self.base_resolver.arguments if self.base_resolver else []
244
239
 
245
240
  return self._arguments
246
241
 
247
242
  @arguments.setter
248
- def arguments(self, value: List[StrawberryArgument]) -> None:
243
+ def arguments(self, value: list[StrawberryArgument]) -> None:
249
244
  self._arguments = value
250
245
 
251
246
  @property
@@ -299,7 +294,7 @@ class StrawberryField(dataclasses.Field):
299
294
  self,
300
295
  ) -> Union[ # type: ignore [valid-type]
301
296
  StrawberryType,
302
- Type[WithStrawberryObjectDefinition],
297
+ type[WithStrawberryObjectDefinition],
303
298
  Literal[UNRESOLVED],
304
299
  ]:
305
300
  return self.resolve_type()
@@ -316,7 +311,7 @@ class StrawberryField(dataclasses.Field):
316
311
 
317
312
  # TODO: add this to arguments (and/or move it to StrawberryType)
318
313
  @property
319
- def type_params(self) -> List[TypeVar]:
314
+ def type_params(self) -> list[TypeVar]:
320
315
  if has_object_definition(self.type):
321
316
  parameters = getattr(self.type, "__parameters__", None)
322
317
 
@@ -334,7 +329,7 @@ class StrawberryField(dataclasses.Field):
334
329
  type_definition: Optional[StrawberryObjectDefinition] = None,
335
330
  ) -> Union[ # type: ignore [valid-type]
336
331
  StrawberryType,
337
- Type[WithStrawberryObjectDefinition],
332
+ type[WithStrawberryObjectDefinition],
338
333
  Literal[UNRESOLVED],
339
334
  ]:
340
335
  # We return UNRESOLVED by default, which means this case will raise a
@@ -385,7 +380,7 @@ class StrawberryField(dataclasses.Field):
385
380
  new_field = copy.copy(self)
386
381
 
387
382
  override_type: Optional[
388
- Union[StrawberryType, Type[WithStrawberryObjectDefinition]]
383
+ Union[StrawberryType, type[WithStrawberryObjectDefinition]]
389
384
  ] = None
390
385
  type_ = self.resolve_type()
391
386
  if has_object_definition(type_):
@@ -431,13 +426,13 @@ def field(
431
426
  is_subscription: bool = False,
432
427
  description: Optional[str] = None,
433
428
  init: Literal[False] = False,
434
- permission_classes: Optional[List[Type[BasePermission]]] = None,
429
+ permission_classes: Optional[list[type[BasePermission]]] = None,
435
430
  deprecation_reason: Optional[str] = None,
436
431
  default: Any = dataclasses.MISSING,
437
432
  default_factory: Union[Callable[..., object], object] = dataclasses.MISSING,
438
433
  metadata: Optional[Mapping[Any, Any]] = None,
439
434
  directives: Optional[Sequence[object]] = (),
440
- extensions: Optional[List[FieldExtension]] = None,
435
+ extensions: Optional[list[FieldExtension]] = None,
441
436
  graphql_type: Optional[Any] = None,
442
437
  ) -> T: ...
443
438
 
@@ -450,13 +445,13 @@ def field(
450
445
  is_subscription: bool = False,
451
446
  description: Optional[str] = None,
452
447
  init: Literal[False] = False,
453
- permission_classes: Optional[List[Type[BasePermission]]] = None,
448
+ permission_classes: Optional[list[type[BasePermission]]] = None,
454
449
  deprecation_reason: Optional[str] = None,
455
450
  default: Any = dataclasses.MISSING,
456
451
  default_factory: Union[Callable[..., object], object] = dataclasses.MISSING,
457
452
  metadata: Optional[Mapping[Any, Any]] = None,
458
453
  directives: Optional[Sequence[object]] = (),
459
- extensions: Optional[List[FieldExtension]] = None,
454
+ extensions: Optional[list[FieldExtension]] = None,
460
455
  graphql_type: Optional[Any] = None,
461
456
  ) -> T: ...
462
457
 
@@ -468,13 +463,13 @@ def field(
468
463
  is_subscription: bool = False,
469
464
  description: Optional[str] = None,
470
465
  init: Literal[True] = True,
471
- permission_classes: Optional[List[Type[BasePermission]]] = None,
466
+ permission_classes: Optional[list[type[BasePermission]]] = None,
472
467
  deprecation_reason: Optional[str] = None,
473
468
  default: Any = dataclasses.MISSING,
474
469
  default_factory: Union[Callable[..., object], object] = dataclasses.MISSING,
475
470
  metadata: Optional[Mapping[Any, Any]] = None,
476
471
  directives: Optional[Sequence[object]] = (),
477
- extensions: Optional[List[FieldExtension]] = None,
472
+ extensions: Optional[list[FieldExtension]] = None,
478
473
  graphql_type: Optional[Any] = None,
479
474
  ) -> Any: ...
480
475
 
@@ -486,13 +481,13 @@ def field(
486
481
  name: Optional[str] = None,
487
482
  is_subscription: bool = False,
488
483
  description: Optional[str] = None,
489
- permission_classes: Optional[List[Type[BasePermission]]] = None,
484
+ permission_classes: Optional[list[type[BasePermission]]] = None,
490
485
  deprecation_reason: Optional[str] = None,
491
486
  default: Any = dataclasses.MISSING,
492
487
  default_factory: Union[Callable[..., object], object] = dataclasses.MISSING,
493
488
  metadata: Optional[Mapping[Any, Any]] = None,
494
489
  directives: Optional[Sequence[object]] = (),
495
- extensions: Optional[List[FieldExtension]] = None,
490
+ extensions: Optional[list[FieldExtension]] = None,
496
491
  graphql_type: Optional[Any] = None,
497
492
  ) -> StrawberryField: ...
498
493
 
@@ -504,13 +499,13 @@ def field(
504
499
  name: Optional[str] = None,
505
500
  is_subscription: bool = False,
506
501
  description: Optional[str] = None,
507
- permission_classes: Optional[List[Type[BasePermission]]] = None,
502
+ permission_classes: Optional[list[type[BasePermission]]] = None,
508
503
  deprecation_reason: Optional[str] = None,
509
504
  default: Any = dataclasses.MISSING,
510
505
  default_factory: Union[Callable[..., object], object] = dataclasses.MISSING,
511
506
  metadata: Optional[Mapping[Any, Any]] = None,
512
507
  directives: Optional[Sequence[object]] = (),
513
- extensions: Optional[List[FieldExtension]] = None,
508
+ extensions: Optional[list[FieldExtension]] = None,
514
509
  graphql_type: Optional[Any] = None,
515
510
  ) -> StrawberryField: ...
516
511
 
@@ -521,13 +516,13 @@ def field(
521
516
  name: Optional[str] = None,
522
517
  is_subscription: bool = False,
523
518
  description: Optional[str] = None,
524
- permission_classes: Optional[List[Type[BasePermission]]] = None,
519
+ permission_classes: Optional[list[type[BasePermission]]] = None,
525
520
  deprecation_reason: Optional[str] = None,
526
521
  default: Any = dataclasses.MISSING,
527
522
  default_factory: Union[Callable[..., object], object] = dataclasses.MISSING,
528
523
  metadata: Optional[Mapping[Any, Any]] = None,
529
524
  directives: Optional[Sequence[object]] = (),
530
- extensions: Optional[List[FieldExtension]] = None,
525
+ extensions: Optional[list[FieldExtension]] = None,
531
526
  graphql_type: Optional[Any] = None,
532
527
  # This init parameter is used by PyRight to determine whether this field
533
528
  # is added in the constructor or not. It is not used to change