24
24
UUID ,
25
25
Union ,
26
26
)
27
+ from graphene .types .base import BaseType
27
28
from graphene .types .datetime import Date , DateTime , Time
28
29
from pydantic import BaseModel
29
30
from pydantic .fields import FieldInfo
30
31
from pydantic_core import PydanticUndefined
31
32
32
- from .registry import Registry
33
+ from .registry import Placeholder , Registry
33
34
from .util import construct_union_class_name , evaluate_forward_ref
34
35
35
36
PYTHON10 = sys .version_info >= (3 , 10 )
@@ -175,7 +176,7 @@ def convert_pydantic_type(
175
176
registry : Registry ,
176
177
parent_type : T .Type = None ,
177
178
model : T .Type [BaseModel ] = None ,
178
- ) -> Type : # noqa: C901
179
+ ) -> T . Union [ Type [ T . Union [ BaseType , List ]], Placeholder ] : # noqa: C901
179
180
"""
180
181
Convert a Pydantic type to a Graphene Field type, including not just the
181
182
native Python type but any additional metadata (e.g. shape) that Pydantic
@@ -197,7 +198,7 @@ def find_graphene_type(
197
198
registry : Registry ,
198
199
parent_type : T .Type = None ,
199
200
model : T .Type [BaseModel ] = None ,
200
- ) -> Type : # noqa: C901
201
+ ) -> T . Union [ Type [ T . Union [ BaseType , List ]], Placeholder ] : # noqa: C901
201
202
"""
202
203
Map a native Python type to a Graphene-supported Field type, where possible,
203
204
throwing an error if we don't know what to map it to.
@@ -303,10 +304,10 @@ def convert_generic_python_type(
303
304
registry : Registry ,
304
305
parent_type : T .Type = None ,
305
306
model : T .Type [BaseModel ] = None ,
306
- ) -> Type : # noqa: C901
307
+ ) -> T . Union [ Type [ T . Union [ BaseType , List ]], Placeholder ] : # noqa: C901
307
308
"""
308
309
Convert annotated Python generic types into the most appropriate Graphene
309
- Field type -- e.g. turn `typing.Union` into a Graphene Union.
310
+ Field type -- e.g., turn `typing.Union` into a Graphene Union.
310
311
"""
311
312
origin = type_ .__origin__
312
313
if not origin : # pragma: no cover # this really should be impossible
@@ -393,7 +394,7 @@ def convert_literal_type(
393
394
registry : Registry ,
394
395
parent_type : T .Type = None ,
395
396
model : T .Type [BaseModel ] = None ,
396
- ):
397
+ ) -> T . Union [ Type [ T . Union [ BaseType , List ]], Placeholder ] :
397
398
"""
398
399
Convert an annotated Python Literal type into a Graphene Scalar or Union of Scalars.
399
400
"""
0 commit comments