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
@@ -30,12 +30,9 @@ from __future__ import annotations
30
30
  import re
31
31
  from dataclasses import dataclass
32
32
  from typing import (
33
+ TYPE_CHECKING,
33
34
  Callable,
34
- Dict,
35
- Iterable,
36
- List,
37
35
  Optional,
38
- Type,
39
36
  Union,
40
37
  )
41
38
 
@@ -61,12 +58,15 @@ from graphql.validation import ValidationContext, ValidationRule
61
58
  from strawberry.extensions import AddValidationRules
62
59
  from strawberry.extensions.utils import is_introspection_key
63
60
 
61
+ if TYPE_CHECKING:
62
+ from collections.abc import Iterable
63
+
64
64
  IgnoreType = Union[Callable[[str], bool], re.Pattern, str]
65
65
 
66
66
  FieldArgumentType = Union[
67
- bool, int, float, str, List["FieldArgumentType"], Dict[str, "FieldArgumentType"]
67
+ bool, int, float, str, list["FieldArgumentType"], dict[str, "FieldArgumentType"]
68
68
  ]
69
- FieldArgumentsType = Dict[str, FieldArgumentType]
69
+ FieldArgumentsType = dict[str, FieldArgumentType]
70
70
 
71
71
 
72
72
  @dataclass
@@ -99,7 +99,7 @@ class QueryDepthLimiter(AddValidationRules):
99
99
  def __init__(
100
100
  self,
101
101
  max_depth: int,
102
- callback: Optional[Callable[[Dict[str, int]], None]] = None,
102
+ callback: Optional[Callable[[dict[str, int]], None]] = None,
103
103
  should_ignore: Optional[ShouldIgnoreType] = None,
104
104
  ) -> None:
105
105
  """Initialize the QueryDepthLimiter.
@@ -123,8 +123,8 @@ class QueryDepthLimiter(AddValidationRules):
123
123
  def create_validator(
124
124
  max_depth: int,
125
125
  should_ignore: Optional[ShouldIgnoreType],
126
- callback: Optional[Callable[[Dict[str, int]], None]] = None,
127
- ) -> Type[ValidationRule]:
126
+ callback: Optional[Callable[[dict[str, int]], None]] = None,
127
+ ) -> type[ValidationRule]:
128
128
  class DepthLimitValidator(ValidationRule):
129
129
  def __init__(self, validation_context: ValidationContext) -> None:
130
130
  document = validation_context.document
@@ -154,7 +154,7 @@ def create_validator(
154
154
 
155
155
  def get_fragments(
156
156
  definitions: Iterable[DefinitionNode],
157
- ) -> Dict[str, FragmentDefinitionNode]:
157
+ ) -> dict[str, FragmentDefinitionNode]:
158
158
  fragments = {}
159
159
  for definition in definitions:
160
160
  if isinstance(definition, FragmentDefinitionNode):
@@ -167,7 +167,7 @@ def get_fragments(
167
167
  # We can basically treat those the same
168
168
  def get_queries_and_mutations(
169
169
  definitions: Iterable[DefinitionNode],
170
- ) -> Dict[str, OperationDefinitionNode]:
170
+ ) -> dict[str, OperationDefinitionNode]:
171
171
  operations = {}
172
172
 
173
173
  for definition in definitions:
@@ -214,7 +214,7 @@ def get_field_arguments(
214
214
 
215
215
  def determine_depth(
216
216
  node: Node,
217
- fragments: Dict[str, FragmentDefinitionNode],
217
+ fragments: dict[str, FragmentDefinitionNode],
218
218
  depth_so_far: int,
219
219
  max_depth: int,
220
220
  context: ValidationContext,
@@ -294,7 +294,7 @@ def determine_depth(
294
294
  raise TypeError(f"Depth crawler cannot handle: {node.kind}") # pragma: no cover
295
295
 
296
296
 
297
- def is_ignored(node: FieldNode, ignore: Optional[List[IgnoreType]] = None) -> bool:
297
+ def is_ignored(node: FieldNode, ignore: Optional[list[IgnoreType]] = None) -> bool:
298
298
  if ignore is None:
299
299
  return False
300
300
 
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import inspect
4
- from typing import TYPE_CHECKING, Any, Dict, List, Optional
4
+ from typing import TYPE_CHECKING, Any, Optional
5
5
 
6
6
  from strawberry.extensions.context import (
7
7
  ExecutingContextManager,
@@ -18,12 +18,12 @@ if TYPE_CHECKING:
18
18
 
19
19
 
20
20
  class SchemaExtensionsRunner:
21
- extensions: List[SchemaExtension]
21
+ extensions: list[SchemaExtension]
22
22
 
23
23
  def __init__(
24
24
  self,
25
25
  execution_context: ExecutionContext,
26
- extensions: Optional[List[SchemaExtension]] = None,
26
+ extensions: Optional[list[SchemaExtension]] = None,
27
27
  ) -> None:
28
28
  self.execution_context = execution_context
29
29
  self.extensions = extensions or []
@@ -40,8 +40,8 @@ class SchemaExtensionsRunner:
40
40
  def executing(self) -> ExecutingContextManager:
41
41
  return ExecutingContextManager(self.extensions)
42
42
 
43
- def get_extensions_results_sync(self) -> Dict[str, Any]:
44
- data: Dict[str, Any] = {}
43
+ def get_extensions_results_sync(self) -> dict[str, Any]:
44
+ data: dict[str, Any] = {}
45
45
  for extension in self.extensions:
46
46
  if inspect.iscoroutinefunction(extension.get_results):
47
47
  msg = "Cannot use async extension hook during sync execution"
@@ -50,8 +50,8 @@ class SchemaExtensionsRunner:
50
50
 
51
51
  return data
52
52
 
53
- async def get_extensions_results(self, ctx: ExecutionContext) -> Dict[str, Any]:
54
- data: Dict[str, Any] = {}
53
+ async def get_extensions_results(self, ctx: ExecutionContext) -> dict[str, Any]:
54
+ data: dict[str, Any] = {}
55
55
 
56
56
  for extension in self.extensions:
57
57
  data.update(await await_maybe(extension.get_results()))
@@ -4,7 +4,7 @@ import dataclasses
4
4
  import time
5
5
  from datetime import datetime, timezone
6
6
  from inspect import isawaitable
7
- from typing import TYPE_CHECKING, Any, Callable, Dict, Generator, List, Optional
7
+ from typing import TYPE_CHECKING, Any, Callable, Optional
8
8
 
9
9
  from strawberry.extensions import SchemaExtension
10
10
  from strawberry.extensions.utils import get_path_from_info
@@ -12,6 +12,8 @@ from strawberry.extensions.utils import get_path_from_info
12
12
  from .utils import should_skip_tracing
13
13
 
14
14
  if TYPE_CHECKING:
15
+ from collections.abc import Generator
16
+
15
17
  from graphql import GraphQLResolveInfo
16
18
 
17
19
  DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
@@ -25,20 +27,20 @@ class ApolloStepStats:
25
27
  start_offset: int
26
28
  duration: int
27
29
 
28
- def to_json(self) -> Dict[str, Any]:
30
+ def to_json(self) -> dict[str, Any]:
29
31
  return {"startOffset": self.start_offset, "duration": self.duration}
30
32
 
31
33
 
32
34
  @dataclasses.dataclass
33
35
  class ApolloResolverStats:
34
- path: List[str]
36
+ path: list[str]
35
37
  parent_type: Any
36
38
  field_name: str
37
39
  return_type: Any
38
40
  start_offset: int
39
41
  duration: Optional[int] = None
40
42
 
41
- def to_json(self) -> Dict[str, Any]:
43
+ def to_json(self) -> dict[str, Any]:
42
44
  return {
43
45
  "path": self.path,
44
46
  "field_name": self.field_name,
@@ -51,9 +53,9 @@ class ApolloResolverStats:
51
53
 
52
54
  @dataclasses.dataclass
53
55
  class ApolloExecutionStats:
54
- resolvers: List[ApolloResolverStats]
56
+ resolvers: list[ApolloResolverStats]
55
57
 
56
- def to_json(self) -> Dict[str, Any]:
58
+ def to_json(self) -> dict[str, Any]:
57
59
  return {"resolvers": [resolver.to_json() for resolver in self.resolvers]}
58
60
 
59
61
 
@@ -67,7 +69,7 @@ class ApolloTracingStats:
67
69
  parsing: ApolloStepStats
68
70
  version: int = 1
69
71
 
70
- def to_json(self) -> Dict[str, Any]:
72
+ def to_json(self) -> dict[str, Any]:
71
73
  return {
72
74
  "version": self.version,
73
75
  "startTime": self.start_time.strftime(DATETIME_FORMAT),
@@ -81,7 +83,7 @@ class ApolloTracingStats:
81
83
 
82
84
  class ApolloTracingExtension(SchemaExtension):
83
85
  def __init__(self, execution_context: ExecutionContext) -> None:
84
- self._resolver_stats: List[ApolloResolverStats] = []
86
+ self._resolver_stats: list[ApolloResolverStats] = []
85
87
  self.execution_context = execution_context
86
88
 
87
89
  def on_operation(self) -> Generator[None, None, None]:
@@ -121,7 +123,7 @@ class ApolloTracingExtension(SchemaExtension):
121
123
  ),
122
124
  )
123
125
 
124
- def get_results(self) -> Dict[str, Dict[str, Any]]:
126
+ def get_results(self) -> dict[str, dict[str, Any]]:
125
127
  return {"tracing": self.stats.to_json()}
126
128
 
127
129
  async def resolve(
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import hashlib
4
4
  from functools import cached_property
5
5
  from inspect import isawaitable
6
- from typing import TYPE_CHECKING, Any, Callable, Generator, Iterator, Optional
6
+ from typing import TYPE_CHECKING, Any, Callable, Optional
7
7
 
8
8
  from ddtrace import Span, tracer
9
9
 
@@ -11,6 +11,8 @@ from strawberry.extensions import LifecycleStep, SchemaExtension
11
11
  from strawberry.extensions.tracing.utils import should_skip_tracing
12
12
 
13
13
  if TYPE_CHECKING:
14
+ from collections.abc import Generator, Iterator
15
+
14
16
  from graphql import GraphQLResolveInfo
15
17
 
16
18
  from strawberry.types.execution import ExecutionContext
@@ -6,12 +6,7 @@ from typing import (
6
6
  TYPE_CHECKING,
7
7
  Any,
8
8
  Callable,
9
- Dict,
10
- FrozenSet,
11
- Generator,
12
- Iterable,
13
9
  Optional,
14
- Set,
15
10
  Union,
16
11
  )
17
12
 
@@ -24,6 +19,8 @@ from strawberry.extensions.utils import get_path_from_info
24
19
  from .utils import should_skip_tracing
25
20
 
26
21
  if TYPE_CHECKING:
22
+ from collections.abc import Generator, Iterable
23
+
27
24
  from graphql import GraphQLResolveInfo
28
25
  from opentelemetry.trace import Span, Tracer
29
26
 
@@ -32,12 +29,12 @@ if TYPE_CHECKING:
32
29
 
33
30
  DATETIME_FORMAT = "%Y-%m-%dT%H:%M:%S.%fZ"
34
31
 
35
- ArgFilter = Callable[[Dict[str, Any], "GraphQLResolveInfo"], Dict[str, Any]]
32
+ ArgFilter = Callable[[dict[str, Any], "GraphQLResolveInfo"], dict[str, Any]]
36
33
 
37
34
 
38
35
  class OpenTelemetryExtension(SchemaExtension):
39
36
  _arg_filter: Optional[ArgFilter]
40
- _span_holder: Dict[LifecycleStep, Span]
37
+ _span_holder: dict[LifecycleStep, Span]
41
38
  _tracer: Tracer
42
39
 
43
40
  def __init__(
@@ -100,8 +97,8 @@ class OpenTelemetryExtension(SchemaExtension):
100
97
  self._span_holder[LifecycleStep.PARSE].end()
101
98
 
102
99
  def filter_resolver_args(
103
- self, args: Dict[str, Any], info: GraphQLResolveInfo
104
- ) -> Dict[str, Any]:
100
+ self, args: dict[str, Any], info: GraphQLResolveInfo
101
+ ) -> dict[str, Any]:
105
102
  if not self._arg_filter:
106
103
  return args
107
104
  return self._arg_filter(deepcopy(args), info)
@@ -132,7 +129,7 @@ class OpenTelemetryExtension(SchemaExtension):
132
129
  else:
133
130
  return str(value)
134
131
 
135
- def convert_set_to_allowed_types(self, value: Union[Set, FrozenSet]) -> str:
132
+ def convert_set_to_allowed_types(self, value: Union[set, frozenset]) -> str:
136
133
  return (
137
134
  "{" + ", ".join(str(self.convert_to_allowed_types(x)) for x in value) + "}"
138
135
  )
@@ -1,6 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import TYPE_CHECKING, List, Union
3
+ from typing import TYPE_CHECKING, Union
4
4
 
5
5
  if TYPE_CHECKING:
6
6
  from graphql import GraphQLResolveInfo
@@ -26,7 +26,7 @@ def is_introspection_field(info: GraphQLResolveInfo) -> bool:
26
26
  return False
27
27
 
28
28
 
29
- def get_path_from_info(info: GraphQLResolveInfo) -> List[str]:
29
+ def get_path_from_info(info: GraphQLResolveInfo) -> list[str]:
30
30
  path = info.path
31
31
  elements = []
32
32
 
@@ -37,4 +37,4 @@ def get_path_from_info(info: GraphQLResolveInfo) -> List[str]:
37
37
  return elements[::-1]
38
38
 
39
39
 
40
- __all__ = ["is_introspection_key", "is_introspection_field", "get_path_from_info"]
40
+ __all__ = ["get_path_from_info", "is_introspection_field", "is_introspection_key"]
@@ -1,5 +1,6 @@
1
+ from collections.abc import Iterator
1
2
  from functools import lru_cache
2
- from typing import Iterator, Optional
3
+ from typing import Optional
3
4
 
4
5
  from strawberry.extensions.base_extension import SchemaExtension
5
6
  from strawberry.schema.execute import validate_document
@@ -1,13 +1,13 @@
1
- from typing import Any, Dict, Optional, Union
1
+ from typing import Any, Optional, Union
2
2
 
3
3
  from starlette.background import BackgroundTasks
4
4
  from starlette.requests import Request
5
5
  from starlette.responses import Response
6
6
  from starlette.websockets import WebSocket
7
7
 
8
- CustomContext = Union["BaseContext", Dict[str, Any]]
8
+ CustomContext = Union["BaseContext", dict[str, Any]]
9
9
  MergedContext = Union[
10
- "BaseContext", Dict[str, Union[Any, BackgroundTasks, Request, Response, WebSocket]]
10
+ "BaseContext", dict[str, Union[Any, BackgroundTasks, Request, Response, WebSocket]]
11
11
  ]
12
12
 
13
13
 
@@ -6,21 +6,15 @@ from inspect import signature
6
6
  from typing import (
7
7
  TYPE_CHECKING,
8
8
  Any,
9
- AsyncIterator,
10
- Awaitable,
11
9
  Callable,
12
- Dict,
13
- List,
14
10
  Optional,
15
- Sequence,
16
- Type,
17
11
  Union,
18
12
  cast,
19
13
  )
20
14
  from typing_extensions import TypeGuard
21
15
 
22
16
  from starlette import status
23
- from starlette.background import BackgroundTasks # noqa: TCH002
17
+ from starlette.background import BackgroundTasks # noqa: TC002
24
18
  from starlette.requests import HTTPConnection, Request
25
19
  from starlette.responses import (
26
20
  HTMLResponse,
@@ -44,6 +38,7 @@ from strawberry.http.typevars import Context, RootValue
44
38
  from strawberry.subscriptions import GRAPHQL_TRANSPORT_WS_PROTOCOL, GRAPHQL_WS_PROTOCOL
45
39
 
46
40
  if TYPE_CHECKING:
41
+ from collections.abc import AsyncIterator, Awaitable, Sequence
47
42
  from enum import Enum
48
43
 
49
44
  from starlette.routing import BaseRoute
@@ -138,16 +133,16 @@ class GraphQLRouter(
138
133
  ),
139
134
  connection_init_wait_timeout: timedelta = timedelta(minutes=1),
140
135
  prefix: str = "",
141
- tags: Optional[List[Union[str, Enum]]] = None,
136
+ tags: Optional[list[Union[str, Enum]]] = None,
142
137
  dependencies: Optional[Sequence[params.Depends]] = None,
143
- default_response_class: Type[Response] = Default(JSONResponse),
144
- responses: Optional[Dict[Union[int, str], Dict[str, Any]]] = None,
145
- callbacks: Optional[List[BaseRoute]] = None,
146
- routes: Optional[List[BaseRoute]] = None,
138
+ default_response_class: type[Response] = Default(JSONResponse),
139
+ responses: Optional[dict[Union[int, str], dict[str, Any]]] = None,
140
+ callbacks: Optional[list[BaseRoute]] = None,
141
+ routes: Optional[list[BaseRoute]] = None,
147
142
  redirect_slashes: bool = True,
148
143
  default: Optional[ASGIApp] = None,
149
144
  dependency_overrides_provider: Optional[Any] = None,
150
- route_class: Type[APIRoute] = APIRoute,
145
+ route_class: type[APIRoute] = APIRoute,
151
146
  on_startup: Optional[Sequence[Callable[[], Any]]] = None,
152
147
  on_shutdown: Optional[Sequence[Callable[[], Any]]] = None,
153
148
  lifespan: Optional[Lifespan[Any]] = None,
@@ -297,7 +292,7 @@ class GraphQLRouter(
297
292
  request: Request,
298
293
  stream: Callable[[], AsyncIterator[str]],
299
294
  sub_response: Response,
300
- headers: Dict[str, str],
295
+ headers: dict[str, str],
301
296
  ) -> Response:
302
297
  return StreamingResponse(
303
298
  stream(),
@@ -2,24 +2,24 @@ from .argument import argument
2
2
  from .enum import enum, enum_value
3
3
  from .field import field
4
4
  from .mutation import mutation
5
- from .object_type import input, interface, interface_object, type
5
+ from .object_type import input, interface, interface_object, type # noqa: A004
6
6
  from .scalar import scalar
7
7
  from .schema import Schema
8
8
  from .schema_directive import schema_directive
9
9
  from .union import union
10
10
 
11
11
  __all__ = [
12
+ "Schema",
12
13
  "argument",
13
14
  "enum",
14
15
  "enum_value",
15
16
  "field",
16
- "mutation",
17
17
  "input",
18
18
  "interface",
19
19
  "interface_object",
20
- "type",
20
+ "mutation",
21
21
  "scalar",
22
- "Schema",
23
22
  "schema_directive",
23
+ "type",
24
24
  "union",
25
25
  ]
@@ -1,4 +1,5 @@
1
- from typing import Iterable, Optional
1
+ from collections.abc import Iterable
2
+ from typing import Optional
2
3
 
3
4
  from strawberry.types.arguments import StrawberryArgumentAnnotation
4
5
 
@@ -4,8 +4,6 @@ from typing import (
4
4
  TYPE_CHECKING,
5
5
  Any,
6
6
  Callable,
7
- Iterable,
8
- List,
9
7
  Optional,
10
8
  Union,
11
9
  overload,
@@ -15,6 +13,8 @@ from strawberry.types.enum import _process_enum
15
13
  from strawberry.types.enum import enum_value as base_enum_value
16
14
 
17
15
  if TYPE_CHECKING:
16
+ from collections.abc import Iterable
17
+
18
18
  from strawberry.enum import EnumType, EnumValueDefinition
19
19
 
20
20
 
@@ -47,8 +47,8 @@ def enum(
47
47
  directives: Iterable[object] = (),
48
48
  authenticated: bool = False,
49
49
  inaccessible: bool = False,
50
- policy: Optional[List[List[str]]] = None,
51
- requires_scopes: Optional[List[List[str]]] = None,
50
+ policy: Optional[list[list[str]]] = None,
51
+ requires_scopes: Optional[list[list[str]]] = None,
52
52
  tags: Optional[Iterable[str]] = (),
53
53
  ) -> EnumType: ...
54
54
 
@@ -62,8 +62,8 @@ def enum(
62
62
  directives: Iterable[object] = (),
63
63
  authenticated: bool = False,
64
64
  inaccessible: bool = False,
65
- policy: Optional[List[List[str]]] = None,
66
- requires_scopes: Optional[List[List[str]]] = None,
65
+ policy: Optional[list[list[str]]] = None,
66
+ requires_scopes: Optional[list[list[str]]] = None,
67
67
  tags: Optional[Iterable[str]] = (),
68
68
  ) -> Callable[[EnumType], EnumType]: ...
69
69
 
@@ -76,8 +76,8 @@ def enum(
76
76
  directives=(),
77
77
  authenticated: bool = False,
78
78
  inaccessible: bool = False,
79
- policy: Optional[List[List[str]]] = None,
80
- requires_scopes: Optional[List[List[str]]] = None,
79
+ policy: Optional[list[list[str]]] = None,
80
+ requires_scopes: Optional[list[list[str]]] = None,
81
81
  tags: Optional[Iterable[str]] = (),
82
82
  ) -> Union[EnumType, Callable[[EnumType], EnumType]]:
83
83
  """Registers the enum in the GraphQL type system.
@@ -5,11 +5,7 @@ from typing import (
5
5
  TYPE_CHECKING,
6
6
  Any,
7
7
  Callable,
8
- Iterable,
9
- List,
10
8
  Optional,
11
- Sequence,
12
- Type,
13
9
  TypeVar,
14
10
  Union,
15
11
  overload,
@@ -19,6 +15,7 @@ from strawberry.types.field import field as base_field
19
15
  from strawberry.types.unset import UNSET
20
16
 
21
17
  if TYPE_CHECKING:
18
+ from collections.abc import Iterable, Sequence
22
19
  from typing_extensions import Literal
23
20
 
24
21
  from strawberry.extensions.field_extension import FieldExtension
@@ -40,20 +37,20 @@ def field(
40
37
  authenticated: bool = False,
41
38
  external: bool = False,
42
39
  inaccessible: bool = False,
43
- policy: Optional[List[List[str]]] = None,
44
- provides: Optional[List[str]] = None,
40
+ policy: Optional[list[list[str]]] = None,
41
+ provides: Optional[list[str]] = None,
45
42
  override: Optional[Union[Override, str]] = None,
46
- requires: Optional[List[str]] = None,
47
- requires_scopes: Optional[List[List[str]]] = None,
43
+ requires: Optional[list[str]] = None,
44
+ requires_scopes: Optional[list[list[str]]] = None,
48
45
  tags: Optional[Iterable[str]] = (),
49
46
  shareable: bool = False,
50
47
  init: Literal[False] = False,
51
- permission_classes: Optional[List[Type[BasePermission]]] = None,
48
+ permission_classes: Optional[list[type[BasePermission]]] = None,
52
49
  deprecation_reason: Optional[str] = None,
53
50
  default: Any = UNSET,
54
51
  default_factory: Union[Callable[..., object], object] = UNSET,
55
52
  directives: Sequence[object] = (),
56
- extensions: Optional[List[FieldExtension]] = None,
53
+ extensions: Optional[list[FieldExtension]] = None,
57
54
  graphql_type: Optional[Any] = None,
58
55
  ) -> T: ...
59
56
 
@@ -67,20 +64,20 @@ def field(
67
64
  authenticated: bool = False,
68
65
  external: bool = False,
69
66
  inaccessible: bool = False,
70
- policy: Optional[List[List[str]]] = None,
71
- provides: Optional[List[str]] = None,
67
+ policy: Optional[list[list[str]]] = None,
68
+ provides: Optional[list[str]] = None,
72
69
  override: Optional[Union[Override, str]] = None,
73
- requires: Optional[List[str]] = None,
74
- requires_scopes: Optional[List[List[str]]] = None,
70
+ requires: Optional[list[str]] = None,
71
+ requires_scopes: Optional[list[list[str]]] = None,
75
72
  tags: Optional[Iterable[str]] = (),
76
73
  shareable: bool = False,
77
74
  init: Literal[True] = True,
78
- permission_classes: Optional[List[Type[BasePermission]]] = None,
75
+ permission_classes: Optional[list[type[BasePermission]]] = None,
79
76
  deprecation_reason: Optional[str] = None,
80
77
  default: Any = UNSET,
81
78
  default_factory: Union[Callable[..., object], object] = UNSET,
82
79
  directives: Sequence[object] = (),
83
- extensions: Optional[List[FieldExtension]] = None,
80
+ extensions: Optional[list[FieldExtension]] = None,
84
81
  graphql_type: Optional[Any] = None,
85
82
  ) -> Any: ...
86
83
 
@@ -95,19 +92,19 @@ def field(
95
92
  authenticated: bool = False,
96
93
  external: bool = False,
97
94
  inaccessible: bool = False,
98
- policy: Optional[List[List[str]]] = None,
99
- provides: Optional[List[str]] = None,
95
+ policy: Optional[list[list[str]]] = None,
96
+ provides: Optional[list[str]] = None,
100
97
  override: Optional[Union[Override, str]] = None,
101
- requires: Optional[List[str]] = None,
102
- requires_scopes: Optional[List[List[str]]] = None,
98
+ requires: Optional[list[str]] = None,
99
+ requires_scopes: Optional[list[list[str]]] = None,
103
100
  tags: Optional[Iterable[str]] = (),
104
101
  shareable: bool = False,
105
- permission_classes: Optional[List[Type[BasePermission]]] = None,
102
+ permission_classes: Optional[list[type[BasePermission]]] = None,
106
103
  deprecation_reason: Optional[str] = None,
107
104
  default: Any = UNSET,
108
105
  default_factory: Union[Callable[..., object], object] = UNSET,
109
106
  directives: Sequence[object] = (),
110
- extensions: Optional[List[FieldExtension]] = None,
107
+ extensions: Optional[list[FieldExtension]] = None,
111
108
  graphql_type: Optional[Any] = None,
112
109
  ) -> StrawberryField: ...
113
110
 
@@ -121,19 +118,19 @@ def field(
121
118
  authenticated: bool = False,
122
119
  external: bool = False,
123
120
  inaccessible: bool = False,
124
- policy: Optional[List[List[str]]] = None,
125
- provides: Optional[List[str]] = None,
121
+ policy: Optional[list[list[str]]] = None,
122
+ provides: Optional[list[str]] = None,
126
123
  override: Optional[Union[Override, str]] = None,
127
- requires: Optional[List[str]] = None,
128
- requires_scopes: Optional[List[List[str]]] = None,
124
+ requires: Optional[list[str]] = None,
125
+ requires_scopes: Optional[list[list[str]]] = None,
129
126
  tags: Optional[Iterable[str]] = (),
130
127
  shareable: bool = False,
131
- permission_classes: Optional[List[Type[BasePermission]]] = None,
128
+ permission_classes: Optional[list[type[BasePermission]]] = None,
132
129
  deprecation_reason: Optional[str] = None,
133
130
  default: Any = dataclasses.MISSING,
134
131
  default_factory: Union[Callable[..., object], object] = dataclasses.MISSING,
135
132
  directives: Sequence[object] = (),
136
- extensions: Optional[List[FieldExtension]] = None,
133
+ extensions: Optional[list[FieldExtension]] = None,
137
134
  graphql_type: Optional[Any] = None,
138
135
  # This init parameter is used by PyRight to determine whether this field
139
136
  # is added in the constructor or not. It is not used to change