strawberry-graphql 0.272.1__py3-none-any.whl → 0.273.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.
@@ -10,6 +10,7 @@ from .duplicated_type_name import DuplicatedTypeName
10
10
  from .exception import StrawberryException, UnableToFindExceptionSource
11
11
  from .handler import setup_exception_handler
12
12
  from .invalid_argument_type import InvalidArgumentTypeError
13
+ from .invalid_superclass_interface import InvalidSuperclassInterfaceError
13
14
  from .invalid_union_type import InvalidTypeForUnionMergeError, InvalidUnionTypeError
14
15
  from .missing_arguments_annotations import MissingArgumentsAnnotationsError
15
16
  from .missing_dependencies import MissingOptionalDependenciesError
@@ -174,6 +175,7 @@ __all__ = [
174
175
  "InvalidArgumentTypeError",
175
176
  "InvalidCustomContext",
176
177
  "InvalidDefaultFactoryError",
178
+ "InvalidSuperclassInterfaceError",
177
179
  "InvalidTypeForUnionMergeError",
178
180
  "InvalidUnionTypeError",
179
181
  "MissingArgumentsAnnotationsError",
@@ -0,0 +1,41 @@
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 collections.abc import Iterable
11
+
12
+ from strawberry.types.base import StrawberryObjectDefinition
13
+
14
+ from .exception_source import ExceptionSource
15
+
16
+
17
+ class InvalidSuperclassInterfaceError(StrawberryException):
18
+ def __init__(
19
+ self,
20
+ cls: type[type],
21
+ input_name: str,
22
+ interfaces: Iterable[StrawberryObjectDefinition],
23
+ ) -> None:
24
+ self.cls = cls
25
+ pretty_interface_names = ", ".join(interface.name for interface in interfaces)
26
+
27
+ self.message = self.rich_message = (
28
+ f"Input class {input_name!r} cannot inherit "
29
+ f"from interface(s): {pretty_interface_names}"
30
+ )
31
+
32
+ self.annotation_message = "input type class defined here"
33
+
34
+ self.suggestion = "To fix this error, make sure your input type class does not inherit from any interfaces."
35
+
36
+ super().__init__(self.message)
37
+
38
+ @cached_property
39
+ def exception_source(self) -> Optional[ExceptionSource]:
40
+ source_finder = SourceFinder()
41
+ return source_finder.find_class_from_object(self.cls)
@@ -15,6 +15,7 @@ from typing import (
15
15
  from typing_extensions import dataclass_transform
16
16
 
17
17
  from strawberry.exceptions import (
18
+ InvalidSuperclassInterfaceError,
18
19
  MissingFieldAnnotationError,
19
20
  MissingReturnAnnotationError,
20
21
  ObjectIsNotClassError,
@@ -151,6 +152,11 @@ def _process_type(
151
152
  is_type_of = getattr(cls, "is_type_of", None)
152
153
  resolve_type = getattr(cls, "resolve_type", None)
153
154
 
155
+ if is_input and interfaces:
156
+ raise InvalidSuperclassInterfaceError(
157
+ cls=cls, input_name=name, interfaces=interfaces
158
+ )
159
+
154
160
  cls.__strawberry_definition__ = StrawberryObjectDefinition( # type: ignore[attr-defined]
155
161
  name=name,
156
162
  is_input=is_input,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: strawberry-graphql
3
- Version: 0.272.1
3
+ Version: 0.273.0
4
4
  Summary: A library for creating GraphQL APIs
5
5
  License: MIT
6
6
  Keywords: graphql,api,rest,starlette,async
@@ -50,13 +50,14 @@ 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=5sAZhCyNiydnQtauI_7H_TRnPfHV3V5d-FKxxDxvTAs,620
52
52
  strawberry/django/views.py,sha256=SiR2fxP42o0IP_Ti8NI2KNlKo0OUwXbEYcJdTzeoK_Q,9686
53
- strawberry/exceptions/__init__.py,sha256=3bo6LehH3CnO3BGol073FhI6eRmV2Mf6OBjf28v6gwY,6515
53
+ strawberry/exceptions/__init__.py,sha256=frr0FLykBb8saILFg4pyvhPN0CY3DdSahBUFwK4Hqf0,6628
54
54
  strawberry/exceptions/conflicting_arguments.py,sha256=FJ5ZlZ_C9O7XS0H9hB0KGRRix0mcB4P6WwIccTJeh-g,1581
55
55
  strawberry/exceptions/duplicated_type_name.py,sha256=Yc8UKO_pTtuXZmkEWp1onBdQitkMSMrfvWfeauLQ-ZI,2204
56
56
  strawberry/exceptions/exception.py,sha256=a_MrBuZtQJD2Zd3pzdNpfuXdJPa6pNX3dz3NpjDSha8,3445
57
57
  strawberry/exceptions/exception_source.py,sha256=Krr9KprJLMuiDBYRzRYULvLIuSjd8gIaiXmPoPCHEDo,404
58
58
  strawberry/exceptions/handler.py,sha256=dY-zaaEcx4pCg5UIKe5BkjSvqk-1D3WxCdh1FtP0eeM,2685
59
59
  strawberry/exceptions/invalid_argument_type.py,sha256=xu239AOYV0zKt4B6y3f4yZfcIJfB5qCcORWJBM9XPQw,2213
60
+ strawberry/exceptions/invalid_superclass_interface.py,sha256=LyIjPVb7k-E0LSAfB6K_PSbOCtvhh2fcKXoykqnzdLA,1293
60
61
  strawberry/exceptions/invalid_union_type.py,sha256=zKxDsagrs4_4ATxSHuPBHY6eQO45S3G1v7b09qQZZ4g,3610
61
62
  strawberry/exceptions/missing_arguments_annotations.py,sha256=-WvTDW75Q2EYFrY3qVZJdbSpAk3UNWkXOnFRDgCzVOk,2007
62
63
  strawberry/exceptions/missing_dependencies.py,sha256=YqMdmXJ_9FnEMFYG6hXyb-1km7N7wsldbat__OigdUQ,832
@@ -212,7 +213,7 @@ strawberry/types/lazy_type.py,sha256=dlP9VcMjZc9sdgriiQGzOZa0TToB6Ee7zpIP8h7TLC0
212
213
  strawberry/types/maybe.py,sha256=Zdv4pAJwgUmaFNU8WKlwjk50qwgYEzT90WteURZBzAo,1174
213
214
  strawberry/types/mutation.py,sha256=cg-_O2WWnZ-GSwOIv0toSdxlGeY2lhBBxZ24AifJuSM,11978
214
215
  strawberry/types/nodes.py,sha256=RwZB43OT9BS3Cqjgq4AazqOfyq_y0GD2ysC86EDBv5U,5134
215
- strawberry/types/object_type.py,sha256=SZOzxaS318079G-pr-1PM5iMoTddxdw8KD4cI67IhzI,15579
216
+ strawberry/types/object_type.py,sha256=SdJF2RWDIrh0C99rEW64rbxMaLokG-J8NLybSqkUrcE,15766
216
217
  strawberry/types/private.py,sha256=DhJs50XVGtOXlxWZFkRpMxQ5_6oki0-x_WQsV1bGUxk,518
217
218
  strawberry/types/scalar.py,sha256=vUWGwAYgcfY26jQUdBJ1tGOvrBq92V0p9L8AWXM7bkk,6384
218
219
  strawberry/types/type_resolver.py,sha256=fH2ZOK4dAGgu8AMPi-JAXe_kEAbvvw2MCYXqbpx-kTc,6529
@@ -231,8 +232,8 @@ strawberry/utils/logging.py,sha256=U1cseHGquN09YFhFmRkiphfASKCyK0HUZREImPgVb0c,7
231
232
  strawberry/utils/operation.py,sha256=CCIREeh3-CzjvjyjhmYPRCVDZUX36jAxF6LbK8r5wEw,1222
232
233
  strawberry/utils/str_converters.py,sha256=-eH1Cl16IO_wrBlsGM-km4IY0IKsjhjnSNGRGOwQjVM,897
233
234
  strawberry/utils/typing.py,sha256=SDvX-Du-9HAV3-XXjqi7Q5f5qPDDFd_gASIITiwBQT4,14073
234
- strawberry_graphql-0.272.1.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
235
- strawberry_graphql-0.272.1.dist-info/METADATA,sha256=To6q3sJkFsHn0QdAkX0QLj0h5sJ-ywhw7u0I35yaikI,7444
236
- strawberry_graphql-0.272.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
237
- strawberry_graphql-0.272.1.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
238
- strawberry_graphql-0.272.1.dist-info/RECORD,,
235
+ strawberry_graphql-0.273.0.dist-info/LICENSE,sha256=m-XnIVUKqlG_AWnfi9NReh9JfKhYOB-gJfKE45WM1W8,1072
236
+ strawberry_graphql-0.273.0.dist-info/METADATA,sha256=D3nGD6vLB5rmHzCwLkSVv3YEBtjIWLI1btDYtfoJ8hY,7444
237
+ strawberry_graphql-0.273.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
238
+ strawberry_graphql-0.273.0.dist-info/entry_points.txt,sha256=Nk7-aT3_uEwCgyqtHESV9H6Mc31cK-VAvhnQNTzTb4k,49
239
+ strawberry_graphql-0.273.0.dist-info/RECORD,,