@@ -1057,34 +1057,34 @@ def serialize(
10571057 @overload
10581058 def serialize (
10591059 self ,
1060- destination : Union [str , BufferedIOBase ],
1060+ destination : Union [str , BufferedIOBase , pathlib . PurePath ],
10611061 format : str = ...,
10621062 base : Optional [str ] = ...,
10631063 encoding : Optional [str ] = ...,
10641064 ** args ,
1065- ) -> None :
1065+ ) -> "Graph" :
10661066 ...
10671067
10681068 # fallback
10691069 @overload
10701070 def serialize (
10711071 self ,
1072- destination : Union [str , BufferedIOBase , None ] = None ,
1072+ destination : Union [str , BufferedIOBase , pathlib . PurePath , None ] = None ,
10731073 format : str = "turtle" ,
10741074 base : Optional [str ] = None ,
10751075 encoding : Optional [str ] = None ,
10761076 ** args ,
1077- ) -> Optional [ Union [bytes , str ] ]:
1077+ ) -> Union [bytes , str , "Graph" ]:
10781078 ...
10791079
10801080 def serialize (
10811081 self ,
1082- destination : Union [str , BufferedIOBase , None ] = None ,
1082+ destination : Union [str , BufferedIOBase , pathlib . PurePath , None ] = None ,
10831083 format : str = "turtle" ,
10841084 base : Optional [str ] = None ,
10851085 encoding : Optional [str ] = None ,
10861086 ** args ,
1087- ) -> Optional [ Union [bytes , str ] ]:
1087+ ) -> Union [bytes , str , "Graph" ]:
10881088 """Serialize the Graph to destination
10891089
10901090 If destination is None serialize method returns the serialization as
@@ -1123,10 +1123,9 @@ def serialize(
11231123 location = cast (str , destination )
11241124 scheme , netloc , path , params , _query , fragment = urlparse (location )
11251125 if netloc != "" :
1126- print (
1127- "WARNING: not saving as location" + " is not a local file reference"
1126+ raise ValueError (
1127+ f"destination { destination } is not a local file reference"
11281128 )
1129- return None
11301129 fd , name = tempfile .mkstemp ()
11311130 stream = os .fdopen (fd , "wb" )
11321131 serializer .serialize (stream , base = base , encoding = encoding , ** args )
0 commit comments