strawberry-graphql 0.193.1__py3-none-any.whl → 0.194.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.
strawberry/annotation.py CHANGED
@@ -52,7 +52,7 @@ ASYNC_TYPES = (
52
52
 
53
53
 
54
54
  class StrawberryAnnotation:
55
- __slots__ = "annotation", "namespace", "__eval_cache__"
55
+ __slots__ = "raw_annotation", "namespace", "__eval_cache__"
56
56
 
57
57
  def __init__(
58
58
  self,
@@ -60,7 +60,7 @@ class StrawberryAnnotation:
60
60
  *,
61
61
  namespace: Optional[Dict[str, Any]] = None,
62
62
  ):
63
- self.annotation = annotation
63
+ self.raw_annotation = annotation
64
64
  self.namespace = namespace
65
65
 
66
66
  self.__eval_cache__: Optional[Type[Any]] = None
@@ -85,13 +85,27 @@ class StrawberryAnnotation:
85
85
  return StrawberryAnnotation(annotation, namespace=namespace)
86
86
  return annotation
87
87
 
88
+ @property
89
+ def annotation(self) -> Union[object, str]:
90
+ """Return evaluated type on success or fallback to raw (string) annotation."""
91
+ try:
92
+ return self.evaluate()
93
+ except NameError:
94
+ # Evaluation failures can happen when importing types within a TYPE_CHECKING
95
+ # block or if the type is declared later on in a module.
96
+ return self.raw_annotation
97
+
98
+ @annotation.setter
99
+ def annotation(self, value: Union[object, str]) -> None:
100
+ self.raw_annotation = value
101
+
88
102
  def evaluate(self) -> type:
89
103
  """Return evaluated annotation using `strawberry.util.typing.eval_type`."""
90
104
  evaled_type = self.__eval_cache__
91
105
  if evaled_type:
92
106
  return evaled_type
93
107
 
94
- annotation = self.annotation
108
+ annotation = self.raw_annotation
95
109
  if isinstance(annotation, str):
96
110
  annotation = ForwardRef(annotation)
97
111
 
strawberry/arguments.py CHANGED
@@ -89,15 +89,11 @@ class StrawberryArgument:
89
89
  _deprecated_UNSET if default is inspect.Parameter.empty else default
90
90
  )
91
91
 
92
- try:
93
- evaled_type = type_annotation.evaluate()
94
- except NameError:
95
- # Evaluation failures can happen when importing types within a TYPE_CHECKING
96
- # block or if the type is declared later on in the current module.
97
- pass
98
- else:
99
- if get_origin(evaled_type) is Annotated:
100
- first, *rest = get_args(evaled_type)
92
+ annotation = type_annotation.annotation
93
+ if not isinstance(annotation, str):
94
+ resolved_annotation = annotation
95
+ if get_origin(resolved_annotation) is Annotated:
96
+ first, *rest = get_args(resolved_annotation)
101
97
 
102
98
  # The first argument to Annotated is always the underlying type
103
99
  self.type_annotation = StrawberryAnnotation(first)
strawberry/auto.py CHANGED
@@ -39,7 +39,7 @@ class StrawberryAutoMeta(type):
39
39
  instance: Union[StrawberryAuto, StrawberryAnnotation, StrawberryType, type],
40
40
  ):
41
41
  if isinstance(instance, StrawberryAnnotation):
42
- resolved = instance.annotation
42
+ resolved = instance.raw_annotation
43
43
  if isinstance(resolved, str):
44
44
  namespace = instance.namespace
45
45
  resolved = namespace and namespace.get(resolved)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strawberry-graphql
3
- Version: 0.193.1
3
+ Version: 0.194.1
4
4
  Summary: A library for creating GraphQL APIs
5
5
  Home-page: https://strawberry.rocks/
6
6
  License: MIT
@@ -7,15 +7,15 @@ strawberry/aiohttp/handlers/graphql_ws_handler.py,sha256=0wy0IjBapHwlkfMhVk6frgp
7
7
  strawberry/aiohttp/test/__init__.py,sha256=4xxdUZtIISSOwjrcnmox7AvT4WWjowCm5bUuPdQneMg,71
8
8
  strawberry/aiohttp/test/client.py,sha256=tlpHymSWqhiQbLmKwodcaX2vdc8BW1IaNTFTHlWKlOY,1323
9
9
  strawberry/aiohttp/views.py,sha256=l85Dy_-e6-19t5szkWn2NQZAkkqSQ-qT47ZXRDXOyfE,5705
10
- strawberry/annotation.py,sha256=tKPuPCkaaZu1OPbWmXe8-TpQzXGk4ZmV7aa8X6Fd3rI,11196
11
- strawberry/arguments.py,sha256=8HmrTQsdvoiTR41Rkzr05xDZpufwjMrHlyxJgB2zdmQ,8369
10
+ strawberry/annotation.py,sha256=U6Iks9S7uYCP4f0GmVRuNpGsbqVmZQesIQLheLLS4tA,11750
11
+ strawberry/arguments.py,sha256=b-jmSwRkC_jDjtJJxD-tO5WnAtuGfhaGgzof0v9QPrE,8231
12
12
  strawberry/asgi/__init__.py,sha256=dXiMHkXfsATl_gDklKnmkgv93SFr6TMqflxV5qzsGIw,6629
13
13
  strawberry/asgi/handlers/__init__.py,sha256=rz5Gth2eJUn7tDq2--99KSNFeMdDPpLFCkfA7vge0cI,235
14
14
  strawberry/asgi/handlers/graphql_transport_ws_handler.py,sha256=czeQetwtgpOliJP81PzUQHjOUa8T8l58nKQsP0NS5ro,2080
15
15
  strawberry/asgi/handlers/graphql_ws_handler.py,sha256=lizGZiwvDe0P581UKyAKerqHrd_L-cljeMxJAD1F114,2321
16
16
  strawberry/asgi/test/__init__.py,sha256=4xxdUZtIISSOwjrcnmox7AvT4WWjowCm5bUuPdQneMg,71
17
17
  strawberry/asgi/test/client.py,sha256=pqxTfWdA8N0Te4pRGxC8TiRcND43LadX-TRo1O_1JJY,1407
18
- strawberry/auto.py,sha256=IYRHAnDau9lV4bcTwtVwflVbVuNNnLn2QGGF5wGi-3Q,2585
18
+ strawberry/auto.py,sha256=aQixog3ZPFqL_o1YYRhYbURUntoOY0UAGzLxT-Wiwi8,2589
19
19
  strawberry/chalice/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  strawberry/chalice/views.py,sha256=pZhN0xGj2HJrmuP1cP382zripNjRUgzeqJZEZltoGCw,4293
21
21
  strawberry/channels/__init__.py,sha256=9oRdAT7uIYETF-23gZ5NteOXSjwkUtwRmwu3YCFv1tw,671
@@ -230,8 +230,8 @@ strawberry/utils/logging.py,sha256=pz1pRJtx5xX2ejGKNN-fG8zPA4SJjnq1HK9xaQpjd4s,1
230
230
  strawberry/utils/operation.py,sha256=Um-tBCPl3_bVFN2Ph7o1mnrxfxBes4HFCj6T0x4kZxE,1135
231
231
  strawberry/utils/str_converters.py,sha256=VdOnzaxhwJnmQl1Lon0VOjl72uXhM8tLfGxoGwn3arI,657
232
232
  strawberry/utils/typing.py,sha256=_PvVDZJrT_iciDvIEwwh4knAog6stKe9sLpxqy00GmI,13182
233
- strawberry_graphql-0.193.1.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
234
- strawberry_graphql-0.193.1.dist-info/METADATA,sha256=Co6TFro7lnIBz5KnbNxdwb8Rl5w8-2dABof1iV8jhis,7634
235
- strawberry_graphql-0.193.1.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
236
- strawberry_graphql-0.193.1.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
237
- strawberry_graphql-0.193.1.dist-info/RECORD,,
233
+ strawberry_graphql-0.194.1.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
234
+ strawberry_graphql-0.194.1.dist-info/METADATA,sha256=ilk-2D0FZdhhvL0PjHAuKhusIdGZVVB_sE8rkGkXoCQ,7634
235
+ strawberry_graphql-0.194.1.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
236
+ strawberry_graphql-0.194.1.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
237
+ strawberry_graphql-0.194.1.dist-info/RECORD,,