@@ -276,9 +276,9 @@ def concat_pdfs(
276276
277277 :param pdf_source: Mapping of filepaths to pdf bytes or an iterable of pdf bytes
278278 :param save_filepath: Filepath to save the concatenated pdf.
279- If `None `, the save_filepath will be taken from the rootdir of the pdf_source
279+ If `True `, the save_filepath will be taken from the rootdir of the pdf_source
280280 that attribute exists, and no file of that name (+'.pdf') exists.
281- If False, the pdf bytes are returned.
281+ If ` False` , the pdf bytes are returned.
282282 :param filter_extensions: If True, only files with recognized extensions
283283 ('.pdf', '.png', '.jpg', '.jpeg', '.bmp', '.gif', '.tiff') are considered
284284 :param key_order: Callable or iterable of keys to sort the mapping
@@ -319,7 +319,7 @@ def concat_pdfs(
319319
320320 if save_filepath is False :
321321 return combined_pdf_bytes
322- elif save_filepath is None :
322+ elif save_filepath is True :
323323 if hasattr (pdf_source , "rootdir" ):
324324 rootdir = pdf_source .rootdir
325325 rootdir_path = Path (rootdir )
@@ -333,6 +333,16 @@ def concat_pdfs(
333333 )
334334 else :
335335 save_filepath = DFLT_SAVE_PDF_NAME
336+ elif save_filepath is None :
337+ # TODO: Deprecating "None" as True as it was before. Change to None == False later
338+ raise ValueError (
339+ "save_filepath must be a string, not None. "
340+ "Specify a filepath to save the concatenated pdf."
341+ )
342+ else :
343+ assert isinstance (
344+ save_filepath , str
345+ ), f"save_filepath must be a boolean or a string, not { save_filepath } "
336346
337347 Path (save_filepath ).write_bytes (combined_pdf_bytes )
338348 return save_filepath
0 commit comments