strawberry-graphql 0.255.0__py3-none-any.whl → 0.256.1__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 +5 -2
  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.1.dist-info}/METADATA +3 -6
  151. strawberry_graphql-0.256.1.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.1.dist-info}/LICENSE +0 -0
  154. {strawberry_graphql-0.255.0.dist-info → strawberry_graphql-0.256.1.dist-info}/WHEEL +0 -0
  155. {strawberry_graphql-0.255.0.dist-info → strawberry_graphql-0.256.1.dist-info}/entry_points.txt +0 -0
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import dataclasses
4
4
  import sys
5
- from typing import Any, Dict, List, Type
5
+ from typing import Any
6
6
 
7
7
  from strawberry.annotation import StrawberryAnnotation
8
8
  from strawberry.exceptions import (
@@ -17,8 +17,8 @@ from strawberry.types.unset import UNSET
17
17
 
18
18
 
19
19
  def _get_fields(
20
- cls: Type[Any], original_type_annotations: Dict[str, Type[Any]]
21
- ) -> List[StrawberryField]:
20
+ cls: type[Any], original_type_annotations: dict[str, type[Any]]
21
+ ) -> list[StrawberryField]:
22
22
  """Get all the strawberry fields off a strawberry.type cls.
23
23
 
24
24
  This function returns a list of StrawberryFields (one for each field item), while
@@ -54,7 +54,7 @@ def _get_fields(
54
54
  passing a named function (i.e. not an anonymous lambda) to strawberry.field
55
55
  (typically as a decorator).
56
56
  """
57
- fields: Dict[str, StrawberryField] = {}
57
+ fields: dict[str, StrawberryField] = {}
58
58
 
59
59
  # before trying to find any fields, let's first add the fields defined in
60
60
  # parent classes, we do this by checking if parents have a type definition
@@ -71,7 +71,7 @@ def _get_fields(
71
71
  # Find the class the each field was originally defined on so we can use
72
72
  # that scope later when resolving the type, as it may have different names
73
73
  # available to it.
74
- origins: Dict[str, type] = {field_name: cls for field_name in cls.__annotations__}
74
+ origins: dict[str, type] = {field_name: cls for field_name in cls.__annotations__}
75
75
 
76
76
  for base in cls.__mro__:
77
77
  if has_object_definition(base):
strawberry/types/union.py CHANGED
@@ -6,20 +6,15 @@ import warnings
6
6
  from itertools import chain
7
7
  from typing import (
8
8
  TYPE_CHECKING,
9
+ Annotated,
9
10
  Any,
10
- Collection,
11
- Iterable,
12
- List,
13
- Mapping,
14
11
  NoReturn,
15
12
  Optional,
16
- Tuple,
17
- Type,
18
13
  TypeVar,
19
14
  Union,
20
15
  cast,
21
16
  )
22
- from typing_extensions import Annotated, get_origin
17
+ from typing_extensions import get_origin
23
18
 
24
19
  from graphql import GraphQLNamedType, GraphQLUnionType
25
20
 
@@ -39,6 +34,8 @@ from strawberry.types.base import (
39
34
  from strawberry.types.lazy_type import LazyType
40
35
 
41
36
  if TYPE_CHECKING:
37
+ from collections.abc import Collection, Iterable, Mapping
38
+
42
39
  from graphql import (
43
40
  GraphQLAbstractType,
44
41
  GraphQLResolveInfo,
@@ -57,7 +54,7 @@ class StrawberryUnion(StrawberryType):
57
54
  def __init__(
58
55
  self,
59
56
  name: Optional[str] = None,
60
- type_annotations: Tuple[StrawberryAnnotation, ...] = tuple(),
57
+ type_annotations: tuple[StrawberryAnnotation, ...] = tuple(),
61
58
  description: Optional[str] = None,
62
59
  directives: Iterable[object] = (),
63
60
  ) -> None:
@@ -94,14 +91,14 @@ class StrawberryUnion(StrawberryType):
94
91
  raise InvalidTypeForUnionMergeError(self, other)
95
92
 
96
93
  @property
97
- def types(self) -> Tuple[StrawberryType, ...]:
94
+ def types(self) -> tuple[StrawberryType, ...]:
98
95
  return tuple(
99
96
  cast(StrawberryType, annotation.resolve())
100
97
  for annotation in self.type_annotations
101
98
  )
102
99
 
103
100
  @property
104
- def type_params(self) -> List[TypeVar]:
101
+ def type_params(self) -> list[TypeVar]:
105
102
  def _get_type_params(type_: StrawberryType) -> list[TypeVar]:
106
103
  if isinstance(type_, LazyType):
107
104
  type_ = cast("StrawberryType", type_.resolve_type())
@@ -240,7 +237,7 @@ class StrawberryUnion(StrawberryType):
240
237
 
241
238
  def union(
242
239
  name: str,
243
- types: Optional[Collection[Type[Any]]] = None,
240
+ types: Optional[Collection[type[Any]]] = None,
244
241
  *,
245
242
  description: Optional[str] = None,
246
243
  directives: Iterable[object] = (),
strawberry/types/unset.py CHANGED
@@ -1,7 +1,7 @@
1
1
  import warnings
2
- from typing import Any, Dict, Optional, Type
2
+ from typing import Any, Optional
3
3
 
4
- DEPRECATED_NAMES: Dict[str, str] = {
4
+ DEPRECATED_NAMES: dict[str, str] = {
5
5
  "is_unset": "`is_unset` is deprecated use `value is UNSET` instead",
6
6
  }
7
7
 
@@ -9,7 +9,7 @@ DEPRECATED_NAMES: Dict[str, str] = {
9
9
  class UnsetType:
10
10
  __instance: Optional["UnsetType"] = None
11
11
 
12
- def __new__(cls: Type["UnsetType"]) -> "UnsetType":
12
+ def __new__(cls: type["UnsetType"]) -> "UnsetType":
13
13
  if cls.__instance is None:
14
14
  ret = super().__new__(cls)
15
15
  cls.__instance = ret
strawberry/utils/aio.py CHANGED
@@ -1,14 +1,9 @@
1
1
  import sys
2
+ from collections.abc import AsyncGenerator, AsyncIterable, AsyncIterator, Awaitable
2
3
  from typing import (
3
4
  Any,
4
- AsyncGenerator,
5
- AsyncIterable,
6
- AsyncIterator,
7
- Awaitable,
8
5
  Callable,
9
- List,
10
6
  Optional,
11
- Tuple,
12
7
  TypeVar,
13
8
  Union,
14
9
  )
@@ -19,7 +14,7 @@ _R = TypeVar("_R")
19
14
 
20
15
  async def aenumerate(
21
16
  iterable: Union[AsyncIterator[_T], AsyncIterable[_T]],
22
- ) -> AsyncIterator[Tuple[int, _T]]:
17
+ ) -> AsyncIterator[tuple[int, _T]]:
23
18
  """Async version of enumerate."""
24
19
  i = 0
25
20
  async for element in iterable:
@@ -56,7 +51,7 @@ async def aislice(
56
51
  return
57
52
 
58
53
 
59
- async def asyncgen_to_list(generator: AsyncGenerator[_T, Any]) -> List[_T]:
54
+ async def asyncgen_to_list(generator: AsyncGenerator[_T, Any]) -> list[_T]:
60
55
  """Convert an async generator to a list."""
61
56
  return [element async for element in generator]
62
57
 
@@ -1,5 +1,6 @@
1
1
  import inspect
2
- from typing import AsyncIterator, Awaitable, Iterator, TypeVar, Union
2
+ from collections.abc import AsyncIterator, Awaitable, Iterator
3
+ from typing import TypeVar, Union
3
4
 
4
5
  T = TypeVar("T")
5
6
 
@@ -14,4 +15,4 @@ async def await_maybe(value: AwaitableOrValue[T]) -> T:
14
15
  return value
15
16
 
16
17
 
17
- __all__ = ["await_maybe", "AwaitableOrValue", "AsyncIteratorOrIterator"]
18
+ __all__ = ["AsyncIteratorOrIterator", "AwaitableOrValue", "await_maybe"]
strawberry/utils/debug.py CHANGED
@@ -1,7 +1,7 @@
1
1
  import datetime
2
2
  import json
3
3
  from json import JSONEncoder
4
- from typing import Any, Dict, Optional
4
+ from typing import Any, Optional
5
5
 
6
6
 
7
7
  class StrawberryJSONEncoder(JSONEncoder):
@@ -10,7 +10,7 @@ class StrawberryJSONEncoder(JSONEncoder):
10
10
 
11
11
 
12
12
  def pretty_print_graphql_operation(
13
- operation_name: Optional[str], query: str, variables: Optional[Dict["str", Any]]
13
+ operation_name: Optional[str], query: str, variables: Optional[dict["str", Any]]
14
14
  ) -> None:
15
15
  """Pretty print a GraphQL operation using pygments.
16
16
 
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import warnings
4
- from typing import Any, Optional, Type
4
+ from typing import Any, Optional
5
5
 
6
6
 
7
7
  class DEPRECATION_MESSAGES:
@@ -19,7 +19,7 @@ class DeprecatedDescriptor:
19
19
  def warn(self) -> None:
20
20
  warnings.warn(self.msg, stacklevel=2)
21
21
 
22
- def __get__(self, obj: Optional[object], type: Optional[Type] = None) -> Any:
22
+ def __get__(self, obj: Optional[object], type: Optional[type] = None) -> Any:
23
23
  self.warn()
24
24
  return self.alias
25
25
 
@@ -4,8 +4,6 @@ from functools import lru_cache
4
4
  from typing import (
5
5
  Any,
6
6
  Callable,
7
- Dict,
8
- List,
9
7
  Optional,
10
8
  TypeVar,
11
9
  get_origin,
@@ -27,7 +25,7 @@ def in_async_context() -> bool:
27
25
 
28
26
 
29
27
  @lru_cache(maxsize=250)
30
- def get_func_args(func: Callable[[Any], Any]) -> List[str]:
28
+ def get_func_args(func: Callable[[Any], Any]) -> list[str]:
31
29
  """Returns a list of arguments for the function."""
32
30
  sig = inspect.signature(func)
33
31
 
@@ -38,7 +36,7 @@ def get_func_args(func: Callable[[Any], Any]) -> List[str]:
38
36
  ]
39
37
 
40
38
 
41
- def get_specialized_type_var_map(cls: type) -> Optional[Dict[str, type]]:
39
+ def get_specialized_type_var_map(cls: type) -> Optional[dict[str, type]]:
42
40
  """Get a type var map for specialized types.
43
41
 
44
42
  Consider the following:
@@ -122,4 +120,4 @@ def get_specialized_type_var_map(cls: type) -> Optional[Dict[str, type]]:
122
120
  return type_var_map
123
121
 
124
122
 
125
- __all__ = ["in_async_context", "get_func_args", "get_specialized_type_var_map"]
123
+ __all__ = ["get_func_args", "get_specialized_type_var_map", "in_async_context"]
@@ -26,4 +26,4 @@ def to_snake_case(name: str) -> str:
26
26
  return re.sub("([a-z0-9])([A-Z])", r"\1_\2", name).lower()
27
27
 
28
28
 
29
- __all__ = ["to_camel_case", "to_kebab_case", "capitalize_first", "to_snake_case"]
29
+ __all__ = ["capitalize_first", "to_camel_case", "to_kebab_case", "to_snake_case"]
@@ -2,19 +2,15 @@ import ast
2
2
  import dataclasses
3
3
  import sys
4
4
  import typing
5
+ from collections.abc import AsyncGenerator
5
6
  from functools import lru_cache
6
7
  from typing import ( # type: ignore
7
- TYPE_CHECKING,
8
+ Annotated,
8
9
  Any,
9
- AsyncGenerator,
10
10
  ClassVar,
11
- Dict,
12
11
  ForwardRef,
13
12
  Generic,
14
- List,
15
13
  Optional,
16
- Tuple,
17
- Type,
18
14
  TypeVar,
19
15
  Union,
20
16
  _eval_type,
@@ -23,22 +19,11 @@ from typing import ( # type: ignore
23
19
  cast,
24
20
  overload,
25
21
  )
26
- from typing_extensions import Annotated, TypeGuard, get_args, get_origin
27
-
28
- ast_unparse = getattr(ast, "unparse", None)
29
- # ast.unparse is only available on python 3.9+. For older versions we will
30
- # use `astunparse.unparse`.
31
- # We are also using "not TYPE_CHECKING" here because mypy gives an erorr
32
- # on tests because "astunparse" is missing stubs, but the mypy action says
33
- # that the comment is unused.
34
- if not TYPE_CHECKING and ast_unparse is None:
35
- import astunparse
36
-
37
- ast_unparse = astunparse.unparse
22
+ from typing_extensions import TypeGuard, get_args, get_origin
38
23
 
39
24
 
40
25
  @lru_cache
41
- def get_generic_alias(type_: Type) -> Type:
26
+ def get_generic_alias(type_: type) -> type:
42
27
  """Get the generic alias for a type.
43
28
 
44
29
  Given a type, its generic alias from `typing` module will be returned
@@ -105,21 +90,21 @@ def is_union(annotation: object) -> bool:
105
90
  return annotation_origin == Union
106
91
 
107
92
 
108
- def is_optional(annotation: Type) -> bool:
93
+ def is_optional(annotation: type) -> bool:
109
94
  """Returns True if the annotation is Optional[SomeType]."""
110
95
  # Optionals are represented as unions
111
96
 
112
97
  if not is_union(annotation):
113
98
  return False
114
99
 
115
- types = annotation.__args__
100
+ types = annotation.__args__ # type: ignore[attr-defined]
116
101
 
117
102
  # A Union to be optional needs to have at least one None type
118
103
  return any(x == None.__class__ for x in types)
119
104
 
120
105
 
121
- def get_optional_annotation(annotation: Type) -> Type:
122
- types = annotation.__args__
106
+ def get_optional_annotation(annotation: type) -> type:
107
+ types = annotation.__args__ # type: ignore[attr-defined]
123
108
 
124
109
  non_none_types = tuple(x for x in types if x != None.__class__)
125
110
 
@@ -127,13 +112,13 @@ def get_optional_annotation(annotation: Type) -> Type:
127
112
  # type (normally a Union type).
128
113
 
129
114
  if len(non_none_types) > 1:
130
- return annotation.copy_with(non_none_types)
115
+ return annotation.copy_with(non_none_types) # type: ignore[attr-defined]
131
116
 
132
117
  return non_none_types[0]
133
118
 
134
119
 
135
- def get_list_annotation(annotation: Type) -> Type:
136
- return annotation.__args__[0]
120
+ def get_list_annotation(annotation: type) -> type:
121
+ return annotation.__args__[0] # type: ignore[attr-defined]
137
122
 
138
123
 
139
124
  def is_concrete_generic(annotation: type) -> bool:
@@ -161,7 +146,7 @@ def is_generic(annotation: type) -> bool:
161
146
  )
162
147
 
163
148
 
164
- def is_type_var(annotation: Type) -> bool:
149
+ def is_type_var(annotation: type) -> bool:
165
150
  """Returns True if the annotation is a TypeVar."""
166
151
  return isinstance(annotation, TypeVar)
167
152
 
@@ -186,7 +171,7 @@ def is_classvar(cls: type, annotation: Union[ForwardRef, str]) -> bool:
186
171
  )
187
172
 
188
173
 
189
- def type_has_annotation(type_: object, annotation: Type) -> bool:
174
+ def type_has_annotation(type_: object, annotation: type) -> bool:
190
175
  """Returns True if the type_ has been annotated with annotation."""
191
176
  if get_origin(type_) is Annotated:
192
177
  return any(isinstance(argument, annotation) for argument in get_args(type_))
@@ -194,14 +179,13 @@ def type_has_annotation(type_: object, annotation: Type) -> bool:
194
179
  return False
195
180
 
196
181
 
197
- def get_parameters(annotation: Type) -> Union[Tuple[object], Tuple[()]]:
198
- if (
199
- isinstance(annotation, _GenericAlias)
200
- or isinstance(annotation, type)
182
+ def get_parameters(annotation: type) -> Union[tuple[object], tuple[()]]:
183
+ if isinstance(annotation, _GenericAlias) or (
184
+ isinstance(annotation, type)
201
185
  and issubclass(annotation, Generic) # type:ignore
202
186
  and annotation is not Generic
203
187
  ):
204
- return annotation.__parameters__
188
+ return annotation.__parameters__ # type: ignore[union-attr]
205
189
  else:
206
190
  return () # pragma: no cover
207
191
 
@@ -238,8 +222,7 @@ def _ast_replace_union_operation(
238
222
  if hasattr(ast, "Index") and isinstance(expr.slice, ast.Index):
239
223
  expr = ast.Subscript(
240
224
  expr.value,
241
- # The cast is required for mypy on python 3.7 and 3.8
242
- ast.Index(_ast_replace_union_operation(cast(Any, expr.slice).value)), # type: ignore
225
+ ast.Index(_ast_replace_union_operation(expr.slice.value)), # type: ignore
243
226
  ast.Load(),
244
227
  )
245
228
  elif isinstance(expr.slice, (ast.BinOp, ast.Tuple)):
@@ -254,9 +237,9 @@ def _ast_replace_union_operation(
254
237
 
255
238
  def _get_namespace_from_ast(
256
239
  expr: Union[ast.Expr, ast.expr],
257
- globalns: Optional[Dict] = None,
258
- localns: Optional[Dict] = None,
259
- ) -> Dict[str, Type]:
240
+ globalns: Optional[dict] = None,
241
+ localns: Optional[dict] = None,
242
+ ) -> dict[str, type]:
260
243
  from strawberry.types.lazy_type import StrawberryLazyReference
261
244
 
262
245
  extra = {}
@@ -274,7 +257,6 @@ def _get_namespace_from_ast(
274
257
  and expr.value.id == "Union"
275
258
  ):
276
259
  if hasattr(ast, "Index") and isinstance(expr.slice, ast.Index):
277
- # The cast is required for mypy on python 3.7 and 3.8
278
260
  expr_slice = cast(Any, expr.slice).value
279
261
  else:
280
262
  expr_slice = expr.slice
@@ -292,18 +274,15 @@ def _get_namespace_from_ast(
292
274
  and isinstance(expr.value, ast.Name)
293
275
  and expr.value.id == "Annotated"
294
276
  ):
295
- assert ast_unparse
296
-
297
277
  if hasattr(ast, "Index") and isinstance(expr.slice, ast.Index):
298
- # The cast is required for mypy on python 3.7 and 3.8
299
278
  expr_slice = cast(Any, expr.slice).value
300
279
  else:
301
280
  expr_slice = expr.slice
302
281
 
303
- args: List[str] = []
282
+ args: list[str] = []
304
283
  for elt in cast(ast.Tuple, expr_slice).elts:
305
284
  extra.update(_get_namespace_from_ast(elt, globalns, localns))
306
- args.append(ast_unparse(elt))
285
+ args.append(ast.unparse(elt))
307
286
 
308
287
  # When using forward refs, the whole
309
288
  # Annotated[SomeType, strawberry.lazy("type.module")] is a forward ref,
@@ -322,16 +301,16 @@ def _get_namespace_from_ast(
322
301
 
323
302
  def eval_type(
324
303
  type_: Any,
325
- globalns: Optional[Dict] = None,
326
- localns: Optional[Dict] = None,
327
- ) -> Type:
304
+ globalns: Optional[dict] = None,
305
+ localns: Optional[dict] = None,
306
+ ) -> type:
328
307
  """Evaluates a type, resolving forward references."""
329
308
  from strawberry.types.auto import StrawberryAuto
330
309
  from strawberry.types.lazy_type import StrawberryLazyReference
331
310
  from strawberry.types.private import StrawberryPrivate
332
311
 
333
312
  globalns = globalns or {}
334
- # If this is not a string, maybe its args are (e.g. List["Foo"])
313
+ # If this is not a string, maybe its args are (e.g. list["Foo"])
335
314
  if isinstance(type_, ForwardRef):
336
315
  ast_obj = cast(ast.Expr, ast.parse(type_.__forward_arg__).body[0])
337
316
 
@@ -347,10 +326,9 @@ def eval_type(
347
326
 
348
327
  globalns.update(_get_namespace_from_ast(ast_obj, globalns, localns))
349
328
 
350
- assert ast_unparse
351
- type_ = ForwardRef(ast_unparse(ast_obj))
329
+ type_ = ForwardRef(ast.unparse(ast_obj))
352
330
 
353
- extra: Dict[str, Any] = {}
331
+ extra: dict[str, Any] = {}
354
332
 
355
333
  if sys.version_info >= (3, 13):
356
334
  extra = {"type_params": None}
@@ -400,13 +378,6 @@ def eval_type(
400
378
  if origin is UnionType:
401
379
  origin = Union
402
380
 
403
- # Future annotations in older versions will eval generic aliases to their
404
- # real types (i.e. List[foo] will have its origin set to list instead
405
- # of List). If that type is not subscriptable, retrieve its generic
406
- # alias version instead.
407
- if sys.version_info < (3, 9) and not hasattr(origin, "__class_getitem__"):
408
- origin = get_generic_alias(origin)
409
-
410
381
  type_ = (
411
382
  origin[tuple(eval_type(a, globalns, localns) for a in args)]
412
383
  if args
@@ -417,19 +388,19 @@ def eval_type(
417
388
 
418
389
 
419
390
  __all__ = [
391
+ "eval_type",
420
392
  "get_generic_alias",
421
- "is_generic_alias",
422
- "is_list",
423
- "is_union",
424
- "is_optional",
425
- "get_optional_annotation",
426
393
  "get_list_annotation",
394
+ "get_optional_annotation",
395
+ "get_parameters",
396
+ "is_classvar",
427
397
  "is_concrete_generic",
428
- "is_generic_subclass",
429
398
  "is_generic",
399
+ "is_generic_alias",
400
+ "is_generic_subclass",
401
+ "is_list",
402
+ "is_optional",
430
403
  "is_type_var",
431
- "is_classvar",
404
+ "is_union",
432
405
  "type_has_annotation",
433
- "get_parameters",
434
- "eval_type",
435
406
  ]
@@ -1,18 +1,17 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strawberry-graphql
3
- Version: 0.255.0
3
+ Version: 0.256.1
4
4
  Summary: A library for creating GraphQL APIs
5
5
  Home-page: https://strawberry.rocks/
6
6
  License: MIT
7
7
  Keywords: graphql,api,rest,starlette,async
8
8
  Author: Patrick Arminio
9
9
  Author-email: patrick.arminio@gmail.com
10
- Requires-Python: >=3.8,<4.0
10
+ Requires-Python: >=3.9,<4.0
11
11
  Classifier: Development Status :: 5 - Production/Stable
12
12
  Classifier: Intended Audience :: Developers
13
13
  Classifier: License :: OSI Approved :: MIT License
14
14
  Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.8
16
15
  Classifier: Programming Language :: Python :: 3.9
17
16
  Classifier: Programming Language :: Python :: 3.10
18
17
  Classifier: Programming Language :: Python :: 3.11
@@ -39,15 +38,13 @@ Provides-Extra: sanic
39
38
  Requires-Dist: Django (>=3.2) ; extra == "django"
40
39
  Requires-Dist: aiohttp (>=3.7.4.post0,<4.0.0) ; extra == "aiohttp"
41
40
  Requires-Dist: asgiref (>=3.2,<4.0) ; extra == "django" or extra == "channels"
42
- Requires-Dist: astunparse (>=1.6.3,<2.0.0) ; python_version < "3.9"
43
41
  Requires-Dist: chalice (>=1.22,<2.0) ; extra == "chalice"
44
42
  Requires-Dist: channels (>=3.0.5) ; extra == "channels"
45
43
  Requires-Dist: fastapi (>=0.65.2) ; extra == "fastapi"
46
44
  Requires-Dist: flask (>=1.1) ; extra == "flask"
47
- Requires-Dist: graphlib_backport ; (python_version < "3.9") and (extra == "cli")
48
45
  Requires-Dist: graphql-core (>=3.2.0,<3.4.0)
49
46
  Requires-Dist: libcst (>=0.4.7) ; extra == "debug" or extra == "debug-server" or extra == "cli"
50
- Requires-Dist: litestar (>=2) ; (python_version >= "3.8") and (extra == "litestar")
47
+ Requires-Dist: litestar (>=2) ; extra == "litestar"
51
48
  Requires-Dist: opentelemetry-api (<2) ; extra == "opentelemetry"
52
49
  Requires-Dist: opentelemetry-sdk (<2) ; extra == "opentelemetry"
53
50
  Requires-Dist: pydantic (>1.6.1) ; extra == "pydantic"