6666except ImportError : # Python < 3.8
6767 from typing_extensions import TypedDict
6868try :
69- from typing import TypeGuard
69+ from typing import TypeAlias , TypeGuard
7070except ImportError : # Python < 3.10
71- from typing_extensions import TypeGuard
71+ from typing_extensions import TypeAlias , TypeGuard
7272
7373if TYPE_CHECKING :
7474 from .schema import GraphQLSchema # noqa: F401
@@ -311,9 +311,9 @@ def __copy__(self) -> GraphQLNamedType: # pragma: no cover
311311
312312T = TypeVar ("T" )
313313
314- ThunkCollection = Union [Callable [[], Collection [T ]], Collection [T ]]
315- ThunkMapping = Union [Callable [[], Mapping [str , T ]], Mapping [str , T ]]
316- Thunk = Union [Callable [[], T ], T ]
314+ ThunkCollection : TypeAlias = Union [Callable [[], Collection [T ]], Collection [T ]]
315+ ThunkMapping : TypeAlias = Union [Callable [[], Mapping [str , T ]], Mapping [str , T ]]
316+ Thunk : TypeAlias = Union [Callable [[], T ], T ]
317317
318318
319319def resolve_thunk (thunk : Thunk [T ]) -> T :
@@ -325,9 +325,11 @@ def resolve_thunk(thunk: Thunk[T]) -> T:
325325 return thunk () if callable (thunk ) else thunk
326326
327327
328- GraphQLScalarSerializer = Callable [[Any ], Any ]
329- GraphQLScalarValueParser = Callable [[Any ], Any ]
330- GraphQLScalarLiteralParser = Callable [[ValueNode , Optional [Dict [str , Any ]]], Any ]
328+ GraphQLScalarSerializer : TypeAlias = Callable [[Any ], Any ]
329+ GraphQLScalarValueParser : TypeAlias = Callable [[Any ], Any ]
330+ GraphQLScalarLiteralParser : TypeAlias = Callable [
331+ [ValueNode , Optional [Dict [str , Any ]]], Any
332+ ]
331333
332334
333335class GraphQLScalarTypeKwargs (GraphQLNamedTypeKwargs , total = False ):
@@ -490,7 +492,7 @@ def assert_scalar_type(type_: Any) -> GraphQLScalarType:
490492 return type_
491493
492494
493- GraphQLArgumentMap = Dict [str , "GraphQLArgument" ]
495+ GraphQLArgumentMap : TypeAlias = Dict [str , "GraphQLArgument" ]
494496
495497
496498class GraphQLFieldKwargs (TypedDict , total = False ):
@@ -633,23 +635,25 @@ class GraphQLResolveInfo(NamedTuple):
633635# Note: Contrary to the Javascript implementation of GraphQLFieldResolver,
634636# the context is passed as part of the GraphQLResolveInfo and any arguments
635637# are passed individually as keyword arguments.
636- GraphQLFieldResolverWithoutArgs = Callable [[Any , GraphQLResolveInfo ], Any ]
638+ GraphQLFieldResolverWithoutArgs : TypeAlias = Callable [[Any , GraphQLResolveInfo ], Any ]
637639# Unfortunately there is currently no syntax to indicate optional or keyword
638640# arguments in Python, so we also allow any other Callable as a workaround:
639- GraphQLFieldResolver = Callable [..., Any ]
641+ GraphQLFieldResolver : TypeAlias = Callable [..., Any ]
640642
641643# Note: Contrary to the Javascript implementation of GraphQLTypeResolver,
642644# the context is passed as part of the GraphQLResolveInfo:
643- GraphQLTypeResolver = Callable [
645+ GraphQLTypeResolver : TypeAlias = Callable [
644646 [Any , GraphQLResolveInfo , "GraphQLAbstractType" ],
645647 AwaitableOrValue [Optional [str ]],
646648]
647649
648650# Note: Contrary to the Javascript implementation of GraphQLIsTypeOfFn,
649651# the context is passed as part of the GraphQLResolveInfo:
650- GraphQLIsTypeOfFn = Callable [[Any , GraphQLResolveInfo ], AwaitableOrValue [bool ]]
652+ GraphQLIsTypeOfFn : TypeAlias = Callable [
653+ [Any , GraphQLResolveInfo ], AwaitableOrValue [bool ]
654+ ]
651655
652- GraphQLFieldMap = Dict [str , GraphQLField ]
656+ GraphQLFieldMap : TypeAlias = Dict [str , GraphQLField ]
653657
654658
655659class GraphQLArgumentKwargs (TypedDict , total = False ):
@@ -1121,7 +1125,7 @@ def assert_union_type(type_: Any) -> GraphQLUnionType:
11211125 return type_
11221126
11231127
1124- GraphQLEnumValueMap = Dict [str , "GraphQLEnumValue" ]
1128+ GraphQLEnumValueMap : TypeAlias = Dict [str , "GraphQLEnumValue" ]
11251129
11261130
11271131class GraphQLEnumTypeKwargs (GraphQLNamedTypeKwargs , total = False ):
@@ -1381,7 +1385,7 @@ def __copy__(self) -> GraphQLEnumValue: # pragma: no cover
13811385 return self .__class__ (** self .to_kwargs ())
13821386
13831387
1384- GraphQLInputFieldMap = Dict [str , "GraphQLInputField" ]
1388+ GraphQLInputFieldMap : TypeAlias = Dict [str , "GraphQLInputField" ]
13851389GraphQLInputFieldOutType = Callable [[Dict [str , Any ]], Any ]
13861390
13871391
@@ -1698,7 +1702,7 @@ def assert_non_null_type(type_: Any) -> GraphQLNonNull:
16981702 GraphQLList ,
16991703)
17001704
1701- GraphQLNullableType = Union [
1705+ GraphQLNullableType : TypeAlias = Union [
17021706 GraphQLScalarType ,
17031707 GraphQLObjectType ,
17041708 GraphQLInterfaceType ,
@@ -1747,7 +1751,7 @@ def get_nullable_type(
17471751
17481752graphql_input_types = (GraphQLScalarType , GraphQLEnumType , GraphQLInputObjectType )
17491753
1750- GraphQLInputType = Union [
1754+ GraphQLInputType : TypeAlias = Union [
17511755 GraphQLScalarType , GraphQLEnumType , GraphQLInputObjectType , GraphQLWrappingType
17521756]
17531757
@@ -1774,7 +1778,7 @@ def assert_input_type(type_: Any) -> GraphQLInputType:
17741778 GraphQLEnumType ,
17751779)
17761780
1777- GraphQLOutputType = Union [
1781+ GraphQLOutputType : TypeAlias = Union [
17781782 GraphQLScalarType ,
17791783 GraphQLObjectType ,
17801784 GraphQLInterfaceType ,
@@ -1798,11 +1802,11 @@ def assert_output_type(type_: Any) -> GraphQLOutputType:
17981802
17991803# These named types do not include modifiers like List or NonNull.
18001804
1801- GraphQLNamedInputType = Union [
1805+ GraphQLNamedInputType : TypeAlias = Union [
18021806 GraphQLScalarType , GraphQLEnumType , GraphQLInputObjectType
18031807]
18041808
1805- GraphQLNamedOutputType = Union [
1809+ GraphQLNamedOutputType : TypeAlias = Union [
18061810 GraphQLScalarType ,
18071811 GraphQLObjectType ,
18081812 GraphQLInterfaceType ,
@@ -1845,7 +1849,7 @@ def get_named_type(type_: Optional[GraphQLType]) -> Optional[GraphQLNamedType]:
18451849
18461850graphql_leaf_types = (GraphQLScalarType , GraphQLEnumType )
18471851
1848- GraphQLLeafType = Union [GraphQLScalarType , GraphQLEnumType ]
1852+ GraphQLLeafType : TypeAlias = Union [GraphQLScalarType , GraphQLEnumType ]
18491853
18501854
18511855def is_leaf_type (type_ : Any ) -> TypeGuard [GraphQLLeafType ]:
@@ -1862,7 +1866,9 @@ def assert_leaf_type(type_: Any) -> GraphQLLeafType:
18621866
18631867graphql_composite_types = (GraphQLObjectType , GraphQLInterfaceType , GraphQLUnionType )
18641868
1865- GraphQLCompositeType = Union [GraphQLObjectType , GraphQLInterfaceType , GraphQLUnionType ]
1869+ GraphQLCompositeType : TypeAlias = Union [
1870+ GraphQLObjectType , GraphQLInterfaceType , GraphQLUnionType
1871+ ]
18661872
18671873
18681874def is_composite_type (type_ : Any ) -> TypeGuard [GraphQLCompositeType ]:
@@ -1879,7 +1885,7 @@ def assert_composite_type(type_: Any) -> GraphQLType:
18791885
18801886graphql_abstract_types = (GraphQLInterfaceType , GraphQLUnionType )
18811887
1882- GraphQLAbstractType = Union [GraphQLInterfaceType , GraphQLUnionType ]
1888+ GraphQLAbstractType : TypeAlias = Union [GraphQLInterfaceType , GraphQLUnionType ]
18831889
18841890
18851891def is_abstract_type (type_ : Any ) -> TypeGuard [GraphQLAbstractType ]:
0 commit comments