strawberry-graphql 0.283.3__py3-none-any.whl → 0.284.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.

Potentially problematic release.


This version of strawberry-graphql might be problematic. Click here for more details.

Files changed (78) hide show
  1. strawberry/aiohttp/views.py +2 -3
  2. strawberry/annotation.py +6 -9
  3. strawberry/asgi/__init__.py +8 -3
  4. strawberry/asgi/test/client.py +1 -1
  5. strawberry/channels/handlers/base.py +3 -3
  6. strawberry/channels/handlers/http_handler.py +3 -3
  7. strawberry/channels/handlers/ws_handler.py +1 -1
  8. strawberry/cli/commands/upgrade/__init__.py +1 -3
  9. strawberry/codegen/query_codegen.py +1 -2
  10. strawberry/codegen/types.py +1 -1
  11. strawberry/dataloader.py +9 -3
  12. strawberry/directive.py +1 -1
  13. strawberry/django/views.py +2 -3
  14. strawberry/exceptions/handler.py +2 -1
  15. strawberry/exceptions/utils/source_finder.py +2 -2
  16. strawberry/experimental/pydantic/_compat.py +3 -2
  17. strawberry/experimental/pydantic/error_type.py +1 -2
  18. strawberry/experimental/pydantic/fields.py +8 -14
  19. strawberry/experimental/pydantic/object_type.py +1 -9
  20. strawberry/ext/mypy_plugin.py +2 -1
  21. strawberry/extensions/base_extension.py +2 -1
  22. strawberry/extensions/context.py +1 -2
  23. strawberry/extensions/directives.py +3 -1
  24. strawberry/extensions/field_extension.py +3 -3
  25. strawberry/extensions/query_depth_limiter.py +1 -1
  26. strawberry/extensions/tracing/apollo.py +2 -2
  27. strawberry/extensions/tracing/datadog.py +2 -2
  28. strawberry/extensions/tracing/opentelemetry.py +1 -1
  29. strawberry/extensions/tracing/utils.py +3 -1
  30. strawberry/fastapi/router.py +2 -2
  31. strawberry/federation/enum.py +1 -2
  32. strawberry/federation/field.py +2 -3
  33. strawberry/federation/object_type.py +1 -2
  34. strawberry/federation/scalar.py +2 -8
  35. strawberry/federation/schema_directive.py +2 -1
  36. strawberry/flask/views.py +1 -1
  37. strawberry/http/__init__.py +2 -2
  38. strawberry/http/async_base_view.py +2 -3
  39. strawberry/http/ides.py +1 -2
  40. strawberry/http/sync_base_view.py +1 -1
  41. strawberry/http/types.py +2 -2
  42. strawberry/litestar/controller.py +8 -3
  43. strawberry/printer/printer.py +2 -1
  44. strawberry/quart/views.py +2 -3
  45. strawberry/relay/fields.py +5 -3
  46. strawberry/relay/types.py +5 -1
  47. strawberry/resolvers.py +2 -1
  48. strawberry/sanic/views.py +2 -3
  49. strawberry/schema/compat.py +1 -1
  50. strawberry/schema/config.py +4 -1
  51. strawberry/schema/schema.py +2 -3
  52. strawberry/schema/schema_converter.py +1 -2
  53. strawberry/schema/types/base_scalars.py +1 -1
  54. strawberry/schema_codegen/__init__.py +2 -2
  55. strawberry/schema_directive.py +2 -1
  56. strawberry/subscriptions/protocols/graphql_transport_ws/types.py +2 -2
  57. strawberry/subscriptions/protocols/graphql_ws/types.py +2 -2
  58. strawberry/test/client.py +2 -2
  59. strawberry/types/arguments.py +2 -1
  60. strawberry/types/auto.py +1 -2
  61. strawberry/types/base.py +7 -5
  62. strawberry/types/enum.py +1 -2
  63. strawberry/types/field.py +6 -8
  64. strawberry/types/fields/resolver.py +3 -3
  65. strawberry/types/maybe.py +11 -2
  66. strawberry/types/mutation.py +3 -4
  67. strawberry/types/object_type.py +2 -21
  68. strawberry/types/scalar.py +2 -7
  69. strawberry/types/union.py +1 -1
  70. strawberry/utils/aio.py +7 -2
  71. strawberry/utils/inspect.py +2 -2
  72. strawberry/utils/typing.py +8 -68
  73. {strawberry_graphql-0.283.3.dist-info → strawberry_graphql-0.284.1.dist-info}/METADATA +2 -2
  74. {strawberry_graphql-0.283.3.dist-info → strawberry_graphql-0.284.1.dist-info}/RECORD +77 -78
  75. strawberry/utils/dataclasses.py +0 -37
  76. {strawberry_graphql-0.283.3.dist-info → strawberry_graphql-0.284.1.dist-info}/WHEEL +0 -0
  77. {strawberry_graphql-0.283.3.dist-info → strawberry_graphql-0.284.1.dist-info}/entry_points.txt +0 -0
  78. {strawberry_graphql-0.283.3.dist-info → strawberry_graphql-0.284.1.dist-info}/licenses/LICENSE +0 -0
strawberry/flask/views.py CHANGED
@@ -5,9 +5,9 @@ from typing import (
5
5
  TYPE_CHECKING,
6
6
  ClassVar,
7
7
  Optional,
8
+ TypeGuard,
8
9
  Union,
9
10
  )
10
- from typing_extensions import TypeGuard
11
11
 
12
12
  from lia import AsyncFlaskHTTPRequestAdapter, FlaskHTTPRequestAdapter, HTTPException
13
13
 
@@ -1,8 +1,8 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from dataclasses import dataclass
4
- from typing import Any, Optional
5
- from typing_extensions import Literal, TypedDict
4
+ from typing import Any, Literal, Optional
5
+ from typing_extensions import TypedDict
6
6
 
7
7
  from strawberry.schema._graphql_core import (
8
8
  GraphQLIncrementalExecutionResults,
@@ -2,19 +2,18 @@ import abc
2
2
  import asyncio
3
3
  import contextlib
4
4
  import json
5
- from collections.abc import AsyncGenerator, Mapping
5
+ from collections.abc import AsyncGenerator, Callable, Mapping
6
6
  from datetime import timedelta
7
7
  from typing import (
8
8
  Any,
9
- Callable,
10
9
  Generic,
11
10
  Literal,
12
11
  Optional,
12
+ TypeGuard,
13
13
  Union,
14
14
  cast,
15
15
  overload,
16
16
  )
17
- from typing_extensions import TypeGuard
18
17
 
19
18
  from graphql import GraphQLError
20
19
  from lia import AsyncHTTPRequestAdapter, HTTPException
strawberry/http/ides.py CHANGED
@@ -1,6 +1,5 @@
1
1
  import pathlib
2
- from typing import Optional
3
- from typing_extensions import Literal
2
+ from typing import Literal, Optional
4
3
 
5
4
  GraphQL_IDE = Literal["graphiql", "apollo-sandbox", "pathfinder"]
6
5
 
@@ -1,7 +1,7 @@
1
1
  import abc
2
2
  import json
3
+ from collections.abc import Callable
3
4
  from typing import (
4
- Callable,
5
5
  Generic,
6
6
  Literal,
7
7
  Optional,
strawberry/http/types.py CHANGED
@@ -1,6 +1,6 @@
1
1
  from collections.abc import Mapping
2
- from typing import Any, Optional
3
- from typing_extensions import Literal, TypedDict
2
+ from typing import Any, Literal, Optional
3
+ from typing_extensions import TypedDict
4
4
 
5
5
  HTTPMethod = Literal[
6
6
  "GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "TRACE"
@@ -8,13 +8,12 @@ from datetime import timedelta
8
8
  from typing import (
9
9
  TYPE_CHECKING,
10
10
  Any,
11
- Callable,
12
11
  ClassVar,
13
12
  Optional,
14
13
  TypedDict,
14
+ TypeGuard,
15
15
  Union,
16
16
  )
17
- from typing_extensions import TypeGuard
18
17
 
19
18
  from lia import HTTPException, LitestarRequestAdapter
20
19
  from msgspec import Struct
@@ -52,7 +51,13 @@ from strawberry.http.typevars import Context, RootValue
52
51
  from strawberry.subscriptions import GRAPHQL_TRANSPORT_WS_PROTOCOL, GRAPHQL_WS_PROTOCOL
53
52
 
54
53
  if TYPE_CHECKING:
55
- from collections.abc import AsyncGenerator, AsyncIterator, Mapping, Sequence
54
+ from collections.abc import (
55
+ AsyncGenerator,
56
+ AsyncIterator,
57
+ Callable,
58
+ Mapping,
59
+ Sequence,
60
+ )
56
61
 
57
62
  from litestar.types import AnyCallable, Dependencies
58
63
  from strawberry.http import GraphQLHTTPResponse
@@ -5,7 +5,6 @@ from itertools import chain
5
5
  from typing import (
6
6
  TYPE_CHECKING,
7
7
  Any,
8
- Callable,
9
8
  Optional,
10
9
  TypeVar,
11
10
  Union,
@@ -46,6 +45,8 @@ from strawberry.types.unset import UNSET
46
45
  from .ast_from_value import ast_from_value
47
46
 
48
47
  if TYPE_CHECKING:
48
+ from collections.abc import Callable
49
+
49
50
  from graphql import (
50
51
  GraphQLArgument,
51
52
  GraphQLEnumType,
strawberry/quart/views.py CHANGED
@@ -1,10 +1,9 @@
1
1
  import asyncio
2
2
  import warnings
3
- from collections.abc import AsyncGenerator, Mapping, Sequence
3
+ from collections.abc import AsyncGenerator, Callable, Mapping, Sequence
4
4
  from datetime import timedelta
5
5
  from json.decoder import JSONDecodeError
6
- from typing import TYPE_CHECKING, Callable, ClassVar, Optional, Union
7
- from typing_extensions import TypeGuard
6
+ from typing import TYPE_CHECKING, ClassVar, Optional, TypeGuard, Union
8
7
 
9
8
  from lia import HTTPException, QuartHTTPRequestAdapter
10
9
 
@@ -8,6 +8,7 @@ from collections.abc import (
8
8
  AsyncIterable,
9
9
  AsyncIterator,
10
10
  Awaitable,
11
+ Callable,
11
12
  Iterable,
12
13
  Iterator,
13
14
  Mapping,
@@ -17,13 +18,13 @@ from typing import (
17
18
  TYPE_CHECKING,
18
19
  Annotated,
19
20
  Any,
20
- Callable,
21
21
  ForwardRef,
22
22
  Optional,
23
23
  Union,
24
24
  cast,
25
+ get_args,
26
+ get_origin,
25
27
  )
26
- from typing_extensions import get_args, get_origin
27
28
 
28
29
  from strawberry.annotation import StrawberryAnnotation
29
30
  from strawberry.extensions.field_extension import (
@@ -47,7 +48,7 @@ from strawberry.utils.typing import eval_type, is_generic_alias, is_optional, is
47
48
  from .types import Connection, GlobalID, Node
48
49
 
49
50
  if TYPE_CHECKING:
50
- from typing_extensions import Literal
51
+ from typing import Literal
51
52
 
52
53
  from strawberry.permission import BasePermission
53
54
  from strawberry.types.info import Info
@@ -180,6 +181,7 @@ class NodeExtension(FieldExtension):
180
181
  for nodes in asyncgen_nodes.values()
181
182
  ),
182
183
  ),
184
+ strict=True,
183
185
  )
184
186
  )
185
187
 
strawberry/relay/types.py CHANGED
@@ -19,13 +19,17 @@ from typing import (
19
19
  ClassVar,
20
20
  ForwardRef,
21
21
  Generic,
22
+ Literal,
22
23
  Optional,
24
+ TypeAlias,
23
25
  TypeVar,
24
26
  Union,
25
27
  cast,
28
+ get_args,
29
+ get_origin,
26
30
  overload,
27
31
  )
28
- from typing_extensions import Literal, Self, TypeAlias, get_args, get_origin
32
+ from typing_extensions import Self
29
33
 
30
34
  from strawberry.relay.exceptions import NodeIDAnnotationError
31
35
  from strawberry.types.base import (
strawberry/resolvers.py CHANGED
@@ -1,4 +1,5 @@
1
- from typing import Any, Callable
1
+ from collections.abc import Callable
2
+ from typing import Any
2
3
 
3
4
 
4
5
  def is_default_resolver(func: Callable[..., Any]) -> bool:
strawberry/sanic/views.py CHANGED
@@ -5,11 +5,10 @@ import warnings
5
5
  from typing import (
6
6
  TYPE_CHECKING,
7
7
  Any,
8
- Callable,
9
8
  Optional,
9
+ TypeGuard,
10
10
  Union,
11
11
  )
12
- from typing_extensions import TypeGuard
13
12
 
14
13
  from lia import HTTPException, SanicHTTPRequestAdapter
15
14
 
@@ -24,7 +23,7 @@ from strawberry.http.typevars import (
24
23
  )
25
24
 
26
25
  if TYPE_CHECKING:
27
- from collections.abc import AsyncGenerator
26
+ from collections.abc import AsyncGenerator, Callable
28
27
 
29
28
  from strawberry.http import GraphQLHTTPResponse
30
29
  from strawberry.http.ides import GraphQL_IDE
@@ -11,7 +11,7 @@ from strawberry.types.base import StrawberryType, has_object_definition
11
11
 
12
12
  if TYPE_CHECKING:
13
13
  from collections.abc import Mapping
14
- from typing_extensions import TypeGuard
14
+ from typing import TypeGuard
15
15
 
16
16
  from strawberry.types.scalar import ScalarDefinition, ScalarWrapper
17
17
 
@@ -1,12 +1,15 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from dataclasses import InitVar, dataclass, field
4
- from typing import Any, Callable, Optional, TypedDict
4
+ from typing import TYPE_CHECKING, Any, Optional, TypedDict
5
5
 
6
6
  from strawberry.types.info import Info
7
7
 
8
8
  from .name_converter import NameConverter
9
9
 
10
+ if TYPE_CHECKING:
11
+ from collections.abc import Callable
12
+
10
13
 
11
14
  class BatchingConfig(TypedDict):
12
15
  max_operations: int
@@ -2,13 +2,12 @@ from __future__ import annotations
2
2
 
3
3
  import warnings
4
4
  from asyncio import ensure_future
5
- from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Iterable
5
+ from collections.abc import AsyncGenerator, AsyncIterator, Awaitable, Callable, Iterable
6
6
  from functools import cached_property, lru_cache
7
7
  from inspect import isawaitable
8
8
  from typing import (
9
9
  TYPE_CHECKING,
10
10
  Any,
11
- Callable,
12
11
  NamedTuple,
13
12
  Optional,
14
13
  Union,
@@ -83,7 +82,7 @@ from .exceptions import CannotGetOperationTypeError, InvalidOperationTypeError
83
82
 
84
83
  if TYPE_CHECKING:
85
84
  from collections.abc import Iterable, Mapping
86
- from typing_extensions import TypeAlias
85
+ from typing import TypeAlias
87
86
 
88
87
  from graphql.language import DocumentNode
89
88
  from graphql.pyutils import Path
@@ -8,7 +8,6 @@ from typing import (
8
8
  TYPE_CHECKING,
9
9
  Annotated,
10
10
  Any,
11
- Callable,
12
11
  Generic,
13
12
  Optional,
14
13
  TypeVar,
@@ -82,7 +81,7 @@ from . import compat
82
81
  from .types.concrete_type import ConcreteType
83
82
 
84
83
  if TYPE_CHECKING:
85
- from collections.abc import Awaitable, Mapping
84
+ from collections.abc import Awaitable, Callable, Mapping
86
85
 
87
86
  from graphql import (
88
87
  GraphQLInputType,
@@ -1,8 +1,8 @@
1
1
  import datetime
2
2
  import decimal
3
3
  import uuid
4
+ from collections.abc import Callable
4
5
  from operator import methodcaller
5
- from typing import Callable
6
6
 
7
7
  import dateutil.parser
8
8
  from graphql import GraphQLError
@@ -4,8 +4,8 @@ import dataclasses
4
4
  import keyword
5
5
  from collections import defaultdict
6
6
  from graphlib import TopologicalSorter
7
- from typing import TYPE_CHECKING, Union
8
- from typing_extensions import Protocol, TypeAlias
7
+ from typing import TYPE_CHECKING, TypeAlias, Union
8
+ from typing_extensions import Protocol
9
9
 
10
10
  import libcst as cst
11
11
  from graphql import (
@@ -1,6 +1,7 @@
1
1
  import dataclasses
2
+ from collections.abc import Callable
2
3
  from enum import Enum
3
- from typing import Callable, Optional, TypeVar
4
+ from typing import Optional, TypeVar
4
5
  from typing_extensions import dataclass_transform
5
6
 
6
7
  from strawberry.types.field import StrawberryField, field
@@ -1,5 +1,5 @@
1
- from typing import TypedDict, Union
2
- from typing_extensions import Literal, NotRequired
1
+ from typing import Literal, TypedDict, Union
2
+ from typing_extensions import NotRequired
3
3
 
4
4
  from graphql import GraphQLFormattedError
5
5
 
@@ -1,5 +1,5 @@
1
- from typing import TypedDict, Union
2
- from typing_extensions import Literal, NotRequired
1
+ from typing import Literal, TypedDict, Union
2
+ from typing_extensions import NotRequired
3
3
 
4
4
  from graphql import GraphQLFormattedError
5
5
 
strawberry/test/client.py CHANGED
@@ -4,8 +4,8 @@ import json
4
4
  import warnings
5
5
  from abc import ABC, abstractmethod
6
6
  from dataclasses import dataclass
7
- from typing import TYPE_CHECKING, Any, Optional, Union
8
- from typing_extensions import Literal, TypedDict
7
+ from typing import TYPE_CHECKING, Any, Literal, Optional, Union
8
+ from typing_extensions import TypedDict
9
9
 
10
10
  if TYPE_CHECKING:
11
11
  from collections.abc import Coroutine, Mapping
@@ -9,8 +9,9 @@ from typing import (
9
9
  Optional,
10
10
  Union,
11
11
  cast,
12
+ get_args,
13
+ get_origin,
12
14
  )
13
- from typing_extensions import get_args, get_origin
14
15
 
15
16
  from strawberry.annotation import StrawberryAnnotation
16
17
  from strawberry.exceptions import MultipleStrawberryArgumentsError, UnsupportedTypeError
strawberry/types/auto.py CHANGED
@@ -1,7 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
- from typing import Annotated, Any, Optional, Union, cast
4
- from typing_extensions import get_args, get_origin
3
+ from typing import Annotated, Any, Optional, Union, cast, get_args, get_origin
5
4
 
6
5
  from strawberry.annotation import StrawberryAnnotation
7
6
  from strawberry.types.base import StrawberryType
strawberry/types/base.py CHANGED
@@ -5,14 +5,14 @@ from abc import ABC, abstractmethod
5
5
  from typing import (
6
6
  TYPE_CHECKING,
7
7
  Any,
8
- Callable,
9
8
  ClassVar,
9
+ Literal,
10
10
  Optional,
11
11
  TypeVar,
12
12
  Union,
13
13
  overload,
14
14
  )
15
- from typing_extensions import Literal, Protocol, Self, deprecated
15
+ from typing_extensions import Protocol, Self, deprecated
16
16
 
17
17
  from strawberry.utils.deprecations import DEPRECATION_MESSAGES, DeprecatedDescriptor
18
18
  from strawberry.utils.inspect import get_specialized_type_var_map
@@ -20,8 +20,8 @@ from strawberry.utils.typing import is_concrete_generic
20
20
  from strawberry.utils.typing import is_generic as is_type_generic
21
21
 
22
22
  if TYPE_CHECKING:
23
- from collections.abc import Mapping, Sequence
24
- from typing_extensions import TypeGuard
23
+ from collections.abc import Callable, Mapping, Sequence
24
+ from typing import TypeGuard
25
25
 
26
26
  from graphql import GraphQLAbstractType, GraphQLResolveInfo
27
27
 
@@ -291,7 +291,9 @@ class StrawberryObjectDefinition(StrawberryType):
291
291
  resolved_type = StrawberryAnnotation(passed_type).resolve()
292
292
  resolved_types.append(resolved_type)
293
293
 
294
- type_var_map = dict(zip((param.__name__ for param in params), resolved_types))
294
+ type_var_map = dict(
295
+ zip((param.__name__ for param in params), resolved_types, strict=True)
296
+ )
295
297
 
296
298
  return self.copy_with(type_var_map)
297
299
 
strawberry/types/enum.py CHANGED
@@ -1,9 +1,8 @@
1
1
  import dataclasses
2
- from collections.abc import Iterable, Mapping
2
+ from collections.abc import Callable, Iterable, Mapping
3
3
  from enum import EnumMeta
4
4
  from typing import (
5
5
  Any,
6
- Callable,
7
6
  Optional,
8
7
  TypeVar,
9
8
  Union,
strawberry/types/field.py CHANGED
@@ -4,12 +4,11 @@ import contextlib
4
4
  import copy
5
5
  import dataclasses
6
6
  import sys
7
- from collections.abc import Awaitable, Coroutine, Mapping, Sequence
7
+ from collections.abc import Awaitable, Callable, Coroutine, Mapping, Sequence
8
8
  from functools import cached_property
9
9
  from typing import (
10
10
  TYPE_CHECKING,
11
11
  Any,
12
- Callable,
13
12
  Optional,
14
13
  TypeVar,
15
14
  Union,
@@ -29,7 +28,8 @@ from .fields.resolver import StrawberryResolver
29
28
 
30
29
  if TYPE_CHECKING:
31
30
  import builtins
32
- from typing_extensions import Literal, Self
31
+ from typing import Literal
32
+ from typing_extensions import Self
33
33
 
34
34
  from strawberry.extensions.field_extension import FieldExtension
35
35
  from strawberry.permission import BasePermission
@@ -92,11 +92,9 @@ class StrawberryField(dataclasses.Field):
92
92
  # basic fields are fields with no provided resolver
93
93
  is_basic_field = not base_resolver
94
94
 
95
- kwargs: Any = {}
96
-
97
- # kw_only was added to python 3.10 and it is required
98
- if sys.version_info >= (3, 10):
99
- kwargs["kw_only"] = dataclasses.MISSING
95
+ kwargs: Any = {
96
+ "kw_only": True,
97
+ }
100
98
 
101
99
  # doc was added to python 3.14 and it is required
102
100
  if sys.version_info >= (3, 14):
@@ -10,15 +10,15 @@ from typing import (
10
10
  TYPE_CHECKING,
11
11
  Annotated,
12
12
  Any,
13
- Callable,
14
13
  Generic,
15
14
  NamedTuple,
16
15
  Optional,
17
16
  TypeVar,
18
17
  Union,
19
18
  cast,
19
+ get_origin,
20
20
  )
21
- from typing_extensions import Protocol, get_origin
21
+ from typing_extensions import Protocol
22
22
 
23
23
  from strawberry.annotation import StrawberryAnnotation
24
24
  from strawberry.exceptions import (
@@ -33,7 +33,7 @@ from strawberry.utils.typing import type_has_annotation
33
33
 
34
34
  if TYPE_CHECKING:
35
35
  import builtins
36
- from collections.abc import Mapping
36
+ from collections.abc import Callable, Mapping
37
37
 
38
38
 
39
39
  class Parameter(inspect.Parameter):
strawberry/types/maybe.py CHANGED
@@ -1,6 +1,6 @@
1
+ import re
1
2
  import typing
2
- from typing import TYPE_CHECKING, Any, Generic, TypeVar, Union
3
- from typing_extensions import TypeAlias
3
+ from typing import TYPE_CHECKING, Any, Generic, TypeAlias, TypeVar, Union
4
4
 
5
5
  T = TypeVar("T")
6
6
 
@@ -37,7 +37,16 @@ else:
37
37
  class Maybe(Generic[T]): ...
38
38
 
39
39
 
40
+ _maybe_re = re.compile(r"^(?:strawberry\.)?Maybe\[(.+)\]$")
41
+
42
+
40
43
  def _annotation_is_maybe(annotation: Any) -> bool:
44
+ if isinstance(annotation, str):
45
+ # Ideally we would try to evaluate the annotation, but the args inside
46
+ # may still not be available, as the module is still being constructed.
47
+ # Checking for the pattern should be good enough for now.
48
+ return _maybe_re.match(annotation) is not None
49
+
41
50
  return (orig := typing.get_origin(annotation)) and orig is Maybe
42
51
 
43
52
 
@@ -4,12 +4,11 @@ import dataclasses
4
4
  from typing import (
5
5
  TYPE_CHECKING,
6
6
  Any,
7
- Callable,
7
+ Literal,
8
8
  Optional,
9
9
  Union,
10
10
  overload,
11
11
  )
12
- from typing_extensions import Literal
13
12
 
14
13
  from strawberry.types.field import (
15
14
  _RESOLVER_TYPE,
@@ -21,8 +20,8 @@ from strawberry.types.field import (
21
20
  )
22
21
 
23
22
  if TYPE_CHECKING:
24
- from collections.abc import Mapping, Sequence
25
- from typing_extensions import Literal
23
+ from collections.abc import Callable, Mapping, Sequence
24
+ from typing import Literal
26
25
 
27
26
  from strawberry.extensions.field_extension import FieldExtension
28
27
  from strawberry.permission import BasePermission
@@ -1,12 +1,10 @@
1
1
  import builtins
2
2
  import dataclasses
3
3
  import inspect
4
- import sys
5
4
  import types
6
- from collections.abc import Sequence
5
+ from collections.abc import Callable, Sequence
7
6
  from typing import (
8
7
  Any,
9
- Callable,
10
8
  Optional,
11
9
  TypeVar,
12
10
  Union,
@@ -105,24 +103,7 @@ def _wrap_dataclass(cls: builtins.type[T]) -> builtins.type[T]:
105
103
  """Wrap a strawberry.type class with a dataclass and check for any issues before doing so."""
106
104
  # Ensure all Fields have been properly type-annotated
107
105
  _check_field_annotations(cls)
108
-
109
- dclass_kwargs: dict[str, bool] = {}
110
-
111
- # Python 3.10 introduces the kw_only param. If we're on an older version
112
- # then generate our own custom init function
113
- if sys.version_info >= (3, 10):
114
- dclass_kwargs["kw_only"] = True
115
- else:
116
- dclass_kwargs["init"] = False
117
-
118
- dclass = dataclasses.dataclass(cls, **dclass_kwargs)
119
-
120
- if sys.version_info < (3, 10):
121
- from strawberry.utils.dataclasses import add_custom_init_fn
122
-
123
- add_custom_init_fn(dclass)
124
-
125
- return dclass
106
+ return dataclasses.dataclass(kw_only=True)(cls)
126
107
 
127
108
 
128
109
  def _inject_default_for_maybe_annotations(
@@ -5,7 +5,6 @@ from dataclasses import dataclass
5
5
  from typing import (
6
6
  TYPE_CHECKING,
7
7
  Any,
8
- Callable,
9
8
  NewType,
10
9
  Optional,
11
10
  TypeVar,
@@ -18,16 +17,12 @@ from strawberry.types.base import StrawberryType
18
17
  from strawberry.utils.str_converters import to_camel_case
19
18
 
20
19
  if TYPE_CHECKING:
21
- from collections.abc import Iterable, Mapping
20
+ from collections.abc import Callable, Iterable, Mapping
22
21
 
23
22
  from graphql import GraphQLScalarType
24
23
 
25
24
 
26
- # in python 3.10+ NewType is a class
27
- if sys.version_info >= (3, 10):
28
- _T = TypeVar("_T", bound=Union[type, NewType])
29
- else:
30
- _T = TypeVar("_T", bound=type)
25
+ _T = TypeVar("_T", bound=Union[type, NewType])
31
26
 
32
27
 
33
28
  def identity(x: _T) -> _T:
strawberry/types/union.py CHANGED
@@ -13,8 +13,8 @@ from typing import (
13
13
  TypeVar,
14
14
  Union,
15
15
  cast,
16
+ get_origin,
16
17
  )
17
- from typing_extensions import get_origin
18
18
 
19
19
  from graphql import GraphQLNamedType, GraphQLUnionType
20
20
 
strawberry/utils/aio.py CHANGED
@@ -1,9 +1,14 @@
1
1
  import sys
2
- from collections.abc import AsyncGenerator, AsyncIterable, AsyncIterator, Awaitable
2
+ from collections.abc import (
3
+ AsyncGenerator,
4
+ AsyncIterable,
5
+ AsyncIterator,
6
+ Awaitable,
7
+ Callable,
8
+ )
3
9
  from contextlib import asynccontextmanager, suppress
4
10
  from typing import (
5
11
  Any,
6
- Callable,
7
12
  Optional,
8
13
  TypeVar,
9
14
  Union,
@@ -1,9 +1,9 @@
1
1
  import asyncio
2
2
  import inspect
3
+ from collections.abc import Callable
3
4
  from functools import lru_cache
4
5
  from typing import (
5
6
  Any,
6
- Callable,
7
7
  Generic,
8
8
  Optional,
9
9
  Protocol,
@@ -99,7 +99,7 @@ def get_specialized_type_var_map(cls: type) -> Optional[dict[str, type]]:
99
99
  if (type_params := getattr(origin, "__parameters__", None)) is not None:
100
100
  args = get_args(tp)
101
101
  if args:
102
- for type_param, arg in zip(type_params, args):
102
+ for type_param, arg in zip(type_params, args, strict=True):
103
103
  if type_param not in param_args:
104
104
  param_args[type_param] = arg
105
105
  else: