We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6c1af33 commit e423286Copy full SHA for e423286
django_pydantic_field/v2/utils.py
@@ -9,13 +9,20 @@
9
if ty.TYPE_CHECKING:
10
from collections.abc import Mapping
11
12
+try:
13
+ from annotationlib import get_annotations # Python >= 3.14
14
+except ImportError:
15
-def get_annotated_type(obj, field, default=None) -> ty.Any:
- try:
16
+ def get_annotations(obj):
17
if isinstance(obj, type):
- annotations = obj.__dict__["__annotations__"]
18
+ return obj.__dict__["__annotations__"]
19
else:
- annotations = obj.__annotations__
20
+ return obj.__annotations__
21
+
22
23
+def get_annotated_type(obj, field, default=None) -> ty.Any:
24
+ try:
25
+ annotations = get_annotations(obj)
26
27
return annotations[field]
28
except (AttributeError, KeyError):
0 commit comments