Skip to content

Commit 13bb05d

Browse files
committed
Use get_annotations from typing_extensions
1 parent 60b55a8 commit 13bb05d

File tree

3 files changed

+4
-17
lines changed

3 files changed

+4
-17
lines changed

poetry.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ classifiers = [
1616
requires-python = ">=3.9,<4.0"
1717
dependencies = [
1818
"graphql-core>=3.2.0,<3.4.0",
19-
"typing-extensions>=4.5.0",
19+
"typing-extensions>=4.13.0",
2020
"python-dateutil~=2.7",
2121
"packaging>=23",
2222
]

strawberry/types/object_type.py

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
Union,
1313
overload,
1414
)
15-
from typing_extensions import dataclass_transform
15+
from typing_extensions import dataclass_transform, get_annotations
1616

1717
from strawberry.exceptions import (
1818
InvalidSuperclassInterfaceError,
@@ -42,19 +42,6 @@ def _get_interfaces(cls: builtins.type[Any]) -> list[StrawberryObjectDefinition]
4242
return interfaces
4343

4444

45-
def _get_annotations(cls: builtins.type[Any]) -> dict[str, Any]:
46-
try:
47-
import annotationlib
48-
49-
annotations = annotationlib.get_annotations(
50-
cls, format=annotationlib.Format.FORWARDREF
51-
)
52-
except ImportError:
53-
annotations = cls.__dict__.get("__annotations__", {})
54-
55-
return annotations
56-
57-
5845
def _check_field_annotations(cls: builtins.type[Any]) -> None:
5946
"""Are any of the dataclass Fields missing type annotations?
6047
@@ -64,7 +51,7 @@ def _check_field_annotations(cls: builtins.type[Any]) -> None:
6451
6552
https://github.com/python/cpython/blob/6fed3c85402c5ca704eb3f3189ca3f5c67a08d19/Lib/dataclasses.py#L881-L884
6653
"""
67-
cls_annotations = _get_annotations(cls)
54+
cls_annotations = get_annotations(cls)
6855
# TODO: do we need this?
6956
cls.__annotations__ = cls_annotations
7057

0 commit comments

Comments
 (0)