strawberry-graphql 0.246.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.
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",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: strawberry-graphql
3
- Version: 0.246.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
@@ -4,8 +4,8 @@ strawberry/aiohttp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuF
4
4
  strawberry/aiohttp/test/__init__.py,sha256=4xxdUZtIISSOwjrcnmox7AvT4WWjowCm5bUuPdQneMg,71
5
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
@@ -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.246.0.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
235
- strawberry_graphql-0.246.0.dist-info/METADATA,sha256=Ek7Jwznh3RRrwACYxYMg-07468ByfUnyqCgwT7gGyWs,7707
236
- strawberry_graphql-0.246.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
237
- strawberry_graphql-0.246.0.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
238
- strawberry_graphql-0.246.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)