@@ -315,8 +315,7 @@ def file_extension(file_format: str) -> str:
315315 }
316316 if file_format in types_with_standard_extension :
317317 return types_with_standard_extension [file_format ]
318- else :
319- raise ValueError ('Provided file format is not a valid one.' )
318+ raise ValueError ('Provided file format is not a valid one.' )
320319
321320 # Formats: 'n3', 'nt', 'turtle', 'xml'
322321 def read (self , location : Union [Path , str ], file_format : str = None ) -> None :
@@ -394,8 +393,7 @@ def add(self,
394393 # Now dispatch to the appropriate method
395394 if isinstance (objects , TopLevel ):
396395 return self ._add (objects )
397- else :
398- return self ._add_all (objects )
396+ return self ._add_all (objects )
399397
400398 def _find_in_objects (self , search_string : str ) -> Optional [Identified ]:
401399 # TODO: implement recursive search
@@ -428,13 +426,19 @@ def join_lines(self, lines: List[Union[bytes, str]]) -> Union[bytes, str]:
428426 """
429427 if not lines :
430428 return ''
431- lines_type = type (lines [0 ])
429+
430+ first_line = lines [0 ]
431+ lines_type = type (first_line )
432+
432433 if lines_type is bytes :
433- # rdflib 5
434- return b'\n ' .join (lines ) + b'\n '
434+ newline = b'\n '
435435 elif lines_type is str :
436- # rdflib 6
437- return '\n ' .join (lines ) + '\n '
436+ newline = '\n '
437+ else :
438+ raise ValueError ("Lines must be either bytes or str" )
439+
440+ joined = newline .join (lines )
441+ return joined + newline
438442
439443 def write_string (self , file_format : str ) -> str :
440444 graph = self .graph ()
0 commit comments