1- from typing import List , Union , cast
1+ from __future__ import annotations
2+
3+ from typing import cast
24
35from graphql .error import GraphQLError
46from graphql .language import (
@@ -204,7 +206,7 @@ def serializes_to_include_message_and_locations():
204206 }
205207
206208 def serializes_to_include_path ():
207- path : List [ Union [ int , str ] ] = ["path" , 3 , "to" , "field" ]
209+ path : list [ int | str ] = ["path" , 3 , "to" , "field" ]
208210 e = GraphQLError ("msg" , path = path )
209211 assert e .path is path
210212 assert repr (e ) == "GraphQLError('msg', path=['path', 3, 'to', 'field'])"
@@ -218,7 +220,7 @@ def serializes_to_include_all_standard_fields():
218220 assert str (e_short ) == "msg"
219221 assert repr (e_short ) == "GraphQLError('msg')"
220222
221- path : List [ Union [ str , int ] ] = ["path" , 2 , "field" ]
223+ path : list [ str | int ] = ["path" , 2 , "field" ]
222224 extensions = {"foo" : "bar " }
223225 e_full = GraphQLError ("msg" , field_node , None , None , path , None , extensions )
224226 assert str (e_full ) == (
@@ -240,7 +242,7 @@ def repr_includes_extensions():
240242 assert repr (e ) == "GraphQLError('msg', extensions={'foo': 'bar'})"
241243
242244 def always_stores_path_as_list ():
243- path : List [ Union [ int , str ] ] = ["path" , 3 , "to" , "field" ]
245+ path : list [ int | str ] = ["path" , 3 , "to" , "field" ]
244246 e = GraphQLError ("msg," , path = tuple (path ))
245247 assert isinstance (e .path , list )
246248 assert e .path == path
@@ -346,7 +348,7 @@ def prints_an_error_with_nodes_from_different_sources():
346348
347349def describe_formatted ():
348350 def formats_graphql_error ():
349- path : List [ Union [ int , str ] ] = ["one" , 2 ]
351+ path : list [ int | str ] = ["one" , 2 ]
350352 extensions = {"ext" : None }
351353 error = GraphQLError (
352354 "test message" ,
@@ -379,7 +381,7 @@ def uses_default_message():
379381 }
380382
381383 def includes_path ():
382- path : List [ Union [ int , str ] ] = ["path" , 3 , "to" , "field" ]
384+ path : list [ int | str ] = ["path" , 3 , "to" , "field" ]
383385 error = GraphQLError ("msg" , path = path )
384386 assert error .formatted == {"message" : "msg" , "path" : path }
385387
0 commit comments