strawberry-graphql 0.245.0__py3-none-any.whl → 0.246.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.
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import warnings
3
4
  from typing import (
4
5
  Any,
5
6
  Dict,
@@ -16,8 +17,9 @@ class GraphQLTestClient(BaseGraphQLTestClient):
16
17
  query: str,
17
18
  variables: Optional[Dict[str, Mapping]] = None,
18
19
  headers: Optional[Dict[str, object]] = None,
19
- asserts_errors: Optional[bool] = True,
20
+ asserts_errors: Optional[bool] = None,
20
21
  files: Optional[Dict[str, object]] = None,
22
+ assert_no_errors: Optional[bool] = True,
21
23
  ) -> Response:
22
24
  body = self._build_body(query, variables, files)
23
25
 
@@ -29,7 +31,19 @@ class GraphQLTestClient(BaseGraphQLTestClient):
29
31
  data=data.get("data"),
30
32
  extensions=data.get("extensions"),
31
33
  )
32
- if asserts_errors:
34
+
35
+ if asserts_errors is not None:
36
+ warnings.warn(
37
+ "The `asserts_errors` argument has been renamed to `assert_no_errors`",
38
+ DeprecationWarning,
39
+ stacklevel=2,
40
+ )
41
+
42
+ assert_no_errors = (
43
+ assert_no_errors if asserts_errors is None else asserts_errors
44
+ )
45
+
46
+ if assert_no_errors:
33
47
  assert resp.status == 200
34
48
  assert response.errors is None
35
49
 
strawberry/annotation.py CHANGED
@@ -20,7 +20,6 @@ from typing import (
20
20
  )
21
21
  from typing_extensions import Annotated, Self, get_args, get_origin
22
22
 
23
- from strawberry.exceptions.not_a_strawberry_enum import NotAStrawberryEnumError
24
23
  from strawberry.types.base import (
25
24
  StrawberryList,
26
25
  StrawberryObjectDefinition,
@@ -30,6 +29,7 @@ from strawberry.types.base import (
30
29
  has_object_definition,
31
30
  )
32
31
  from strawberry.types.enum import EnumDefinition
32
+ from strawberry.types.enum import enum as strawberry_enum
33
33
  from strawberry.types.lazy_type import LazyType
34
34
  from strawberry.types.private import is_private
35
35
  from strawberry.types.scalar import ScalarDefinition
@@ -187,7 +187,7 @@ class StrawberryAnnotation:
187
187
  try:
188
188
  return evaled_type._enum_definition
189
189
  except AttributeError:
190
- raise NotAStrawberryEnumError(evaled_type)
190
+ return strawberry_enum(evaled_type)._enum_definition
191
191
 
192
192
  def create_list(self, evaled_type: Any) -> StrawberryList:
193
193
  item_type, *_ = get_args(evaled_type)
@@ -186,7 +186,7 @@ class GraphQL(
186
186
 
187
187
  return sub_response
188
188
 
189
- async def render_graphql_ide(self, request: Union[Request, WebSocket]) -> Response:
189
+ async def render_graphql_ide(self, request: Request) -> Response:
190
190
  return HTMLResponse(self.graphql_ide_html)
191
191
 
192
192
  def create_response(
@@ -15,7 +15,6 @@ from .missing_arguments_annotations import MissingArgumentsAnnotationsError
15
15
  from .missing_dependencies import MissingOptionalDependenciesError
16
16
  from .missing_field_annotation import MissingFieldAnnotationError
17
17
  from .missing_return_annotation import MissingReturnAnnotationError
18
- from .not_a_strawberry_enum import NotAStrawberryEnumError
19
18
  from .object_is_not_a_class import ObjectIsNotClassError
20
19
  from .object_is_not_an_enum import ObjectIsNotAnEnumError
21
20
  from .private_strawberry_field import PrivateStrawberryFieldError
@@ -174,7 +173,6 @@ __all__ = [
174
173
  "UnresolvedFieldTypeError",
175
174
  "PrivateStrawberryFieldError",
176
175
  "MultipleStrawberryArgumentsError",
177
- "NotAStrawberryEnumError",
178
176
  "ScalarAlreadyRegisteredError",
179
177
  "WrongNumberOfResultsReturned",
180
178
  "FieldWithResolverAndDefaultValueError",
strawberry/test/client.py CHANGED
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import json
4
+ import warnings
4
5
  from abc import ABC, abstractmethod
5
6
  from dataclasses import dataclass
6
7
  from typing import TYPE_CHECKING, Any, Coroutine, Dict, List, Mapping, Optional, Union
@@ -36,8 +37,9 @@ class BaseGraphQLTestClient(ABC):
36
37
  query: str,
37
38
  variables: Optional[Dict[str, Mapping]] = None,
38
39
  headers: Optional[Dict[str, object]] = None,
39
- asserts_errors: Optional[bool] = True,
40
+ asserts_errors: Optional[bool] = None,
40
41
  files: Optional[Dict[str, object]] = None,
42
+ assert_no_errors: Optional[bool] = True,
41
43
  ) -> Union[Coroutine[Any, Any, Response], Response]:
42
44
  body = self._build_body(query, variables, files)
43
45
 
@@ -49,7 +51,19 @@ class BaseGraphQLTestClient(ABC):
49
51
  data=data.get("data"),
50
52
  extensions=data.get("extensions"),
51
53
  )
52
- if asserts_errors:
54
+
55
+ if asserts_errors is not None:
56
+ warnings.warn(
57
+ "The `asserts_errors` argument has been renamed to `assert_no_errors`",
58
+ DeprecationWarning,
59
+ stacklevel=2,
60
+ )
61
+
62
+ assert_no_errors = (
63
+ assert_no_errors if asserts_errors is None else asserts_errors
64
+ )
65
+
66
+ if assert_no_errors:
53
67
  assert response.errors is None
54
68
 
55
69
  return response
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strawberry-graphql
3
- Version: 0.245.0
3
+ Version: 0.246.1
4
4
  Summary: A library for creating GraphQL APIs
5
5
  Home-page: https://strawberry.rocks/
6
6
  License: MIT
@@ -2,10 +2,10 @@ strawberry/__init__.py,sha256=tJOqxIEg3DYPe48P952sMjF3IxxZqZfIY-kNRlbwBNg,1374
2
2
  strawberry/__main__.py,sha256=3U77Eu21mJ-LY27RG-JEnpbh6Z63wGOom4i-EoLtUcY,59
3
3
  strawberry/aiohttp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  strawberry/aiohttp/test/__init__.py,sha256=4xxdUZtIISSOwjrcnmox7AvT4WWjowCm5bUuPdQneMg,71
5
- strawberry/aiohttp/test/client.py,sha256=4vjTDxtNVfpa74GfUUO7efPI6Ssh1vzfCYp3tPA-SLk,1357
5
+ strawberry/aiohttp/test/client.py,sha256=xPwOo1V0XbC86LWHiSRTLcGNOa796flz49wzWmdkvSs,1775
6
6
  strawberry/aiohttp/views.py,sha256=wbJkcQ1u98tuHa3_mq8OCGzSm57Nnw4DnS5qkILHlEo,7487
7
- strawberry/annotation.py,sha256=ftSxGZQUk4C5_5YRM_wNJFVVnZi0XOp71kD7zv4oxbU,13077
8
- strawberry/asgi/__init__.py,sha256=aFM74LpXxTruW5a00Ry9rIi3vz7hgnELJvZqPwJnhcY,7645
7
+ strawberry/annotation.py,sha256=u5rkFs6CDUaiJZMK7jp_VDUWdZZ3HXQEbR2ocruDpxA,13065
8
+ strawberry/asgi/__init__.py,sha256=aAZxRFESgbDNXzByT_O9oocolwCj4wB491w6jYKKsiU,7627
9
9
  strawberry/asgi/test/__init__.py,sha256=4xxdUZtIISSOwjrcnmox7AvT4WWjowCm5bUuPdQneMg,71
10
10
  strawberry/asgi/test/client.py,sha256=VolupxMna9ktF1lYgV_dUQAIN53DNzVyWTeWTbwsxqE,1448
11
11
  strawberry/chalice/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -50,7 +50,7 @@ strawberry/django/context.py,sha256=XL85jDGAVnb2pwgm5uRUvIXwlGia3i-8ZVfKihf0T24,
50
50
  strawberry/django/test/__init__.py,sha256=4xxdUZtIISSOwjrcnmox7AvT4WWjowCm5bUuPdQneMg,71
51
51
  strawberry/django/test/client.py,sha256=6dorWECd0wdn8fu3dabE-dfGK3uza58mGrdJ-xPct-w,626
52
52
  strawberry/django/views.py,sha256=b0DgNAKqKlM0CTOipDLUPm9liS_02wLJaZuxIaIR1Xk,9573
53
- strawberry/exceptions/__init__.py,sha256=DgdOJUs2xXHWcakr4tN6iIogltPi0MNnpu6MM6K0p5k,6347
53
+ strawberry/exceptions/__init__.py,sha256=-yYcgv3cxEyDSxWyFId9j-yy2pNnXQC4lIpk7bHr8fs,6257
54
54
  strawberry/exceptions/conflicting_arguments.py,sha256=68f6kMSXdjuEjZkoe8o2I9PSIjwTS1kXsSGaQBPk_hI,1587
55
55
  strawberry/exceptions/duplicated_type_name.py,sha256=-FG5qG_Mvkd7ROdOxCB9bijf8QR6Olryf07mbAFC0-U,2210
56
56
  strawberry/exceptions/exception.py,sha256=1NrsTAzko1fUrSpXjYpNoCk2XuYJerEKj_CDeqGe_eA,3447
@@ -62,7 +62,6 @@ strawberry/exceptions/missing_arguments_annotations.py,sha256=1P34Iemkisvgkr-3yE
62
62
  strawberry/exceptions/missing_dependencies.py,sha256=YqMdmXJ_9FnEMFYG6hXyb-1km7N7wsldbat__OigdUQ,832
63
63
  strawberry/exceptions/missing_field_annotation.py,sha256=sZ94_b7GlFZ-KR2S1VyXFx8MV2E7uFITg9wcvWhv1Mk,1338
64
64
  strawberry/exceptions/missing_return_annotation.py,sha256=w7uHlEdSl86nZkLva12ErXV8rnNv6NcXn_dDBtag6fs,1405
65
- strawberry/exceptions/not_a_strawberry_enum.py,sha256=MC7zbNvINTluywuVGX4oBFJzPw9Uy2M0a4A3VkQqDYI,1105
66
65
  strawberry/exceptions/object_is_not_a_class.py,sha256=pfPdVNbcdkqQanJf9G-NAHy0QR3Bx1hCUg_Kn_25g-0,2008
67
66
  strawberry/exceptions/object_is_not_an_enum.py,sha256=cJnqE23zXMYLd_NfN9UYkHU270EJjEGL6oNC-cCNx_Y,1269
68
67
  strawberry/exceptions/permission_fail_silently_requires_optional.py,sha256=iQPxvVmRxaZQ__TO6Pv_Bwzs-9wDX5woPBtK9XK42i0,1735
@@ -194,7 +193,7 @@ strawberry/subscriptions/protocols/graphql_ws/__init__.py,sha256=ijn1A1O0Fzv5p9n
194
193
  strawberry/subscriptions/protocols/graphql_ws/handlers.py,sha256=QxCribyj-EP9SFblbUd4GxK4dMdJe-P8TsjYPwaXf-8,7556
195
194
  strawberry/subscriptions/protocols/graphql_ws/types.py,sha256=CKm4Hy95p6H9u_-QyWdxipwzNeeDIWtilP3RRp8vjPw,1050
196
195
  strawberry/test/__init__.py,sha256=U3B5Ng7C_H8GpCpfvgZZcfADMw6cor5hm78gS3nDdMI,115
197
- strawberry/test/client.py,sha256=-V_5DakR0NJ_Kd5ww4leIhMnIJ-Pf274HkNqYtGVfl8,6044
196
+ strawberry/test/client.py,sha256=Va7J1tIjZ6PxbOqPl57jSp5lNLOZSueHPmrUuUx5sRY,6462
198
197
  strawberry/tools/__init__.py,sha256=pdGpZx8wpq03VfUZJyF9JtYxZhGqzzxCiipsalWxJX4,127
199
198
  strawberry/tools/create_type.py,sha256=jY-6J4VTSrzqc-NbDZpNv7U9L1j1aun5KNGTaGgNcls,2041
200
199
  strawberry/tools/merge_types.py,sha256=noMPqGfbqUaMYMwT_db1rUMaPmmR_uHeFwx7Zd0rivE,1048
@@ -231,8 +230,8 @@ strawberry/utils/logging.py,sha256=U1cseHGquN09YFhFmRkiphfASKCyK0HUZREImPgVb0c,7
231
230
  strawberry/utils/operation.py,sha256=SSXxN-vMqdHO6W2OZtip-1z7y4_A-eTVFdhDvhKeLCk,1193
232
231
  strawberry/utils/str_converters.py,sha256=KGd7QH90RevaJjH6SQEkiVVsb8KuhJr_wv5AsI7UzQk,897
233
232
  strawberry/utils/typing.py,sha256=3xws5kxSQGsp8BnYyUwClvxXNzZakMAuOPoq1rjHRuk,14252
234
- strawberry_graphql-0.245.0.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
235
- strawberry_graphql-0.245.0.dist-info/METADATA,sha256=8mvtyQQnC5lVbvaC5qVhpUXF0q2McBlm39inhtj3F18,7707
236
- strawberry_graphql-0.245.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
237
- strawberry_graphql-0.245.0.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
238
- strawberry_graphql-0.245.0.dist-info/RECORD,,
233
+ strawberry_graphql-0.246.1.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
234
+ strawberry_graphql-0.246.1.dist-info/METADATA,sha256=yHx-6GGaONdjjvt4YmaKfnjqFISvrnVxSNXwRS5jjb4,7707
235
+ strawberry_graphql-0.246.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
236
+ strawberry_graphql-0.246.1.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
237
+ strawberry_graphql-0.246.1.dist-info/RECORD,,
@@ -1,38 +0,0 @@
1
- from __future__ import annotations
2
-
3
- from functools import cached_property
4
- from typing import TYPE_CHECKING, Optional
5
-
6
- from .exception import StrawberryException
7
- from .utils.source_finder import SourceFinder
8
-
9
- if TYPE_CHECKING:
10
- from enum import EnumMeta
11
-
12
- from .exception_source import ExceptionSource
13
-
14
-
15
- class NotAStrawberryEnumError(StrawberryException):
16
- def __init__(self, enum: EnumMeta) -> None:
17
- self.enum = enum
18
-
19
- self.message = f'Enum "{enum.__name__}" is not a Strawberry enum.'
20
- self.rich_message = (
21
- f"Enum `[underline]{enum.__name__}[/]` is not a Strawberry enum."
22
- )
23
- self.suggestion = (
24
- "To fix this error you can declare the enum using `@strawberry.enum`."
25
- )
26
-
27
- self.annotation_message = "enum defined here"
28
-
29
- super().__init__(self.message)
30
-
31
- @cached_property
32
- def exception_source(self) -> Optional[ExceptionSource]:
33
- if self.enum is None:
34
- return None # pragma: no cover
35
-
36
- source_finder = SourceFinder()
37
-
38
- return source_finder.find_class_from_object(self.enum)