mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Let ruff autofix some things from the newest version
This commit is contained in:
		| @@ -28,7 +28,7 @@ if __name__ == "__main__": | |||||||
|             except Exception as e: |             except Exception as e: | ||||||
|                 print( |                 print( | ||||||
|                     f"Redis ping #{attempt} failed.\n" |                     f"Redis ping #{attempt} failed.\n" | ||||||
|                     f"Error: {str(e)}.\n" |                     f"Error: {e!s}.\n" | ||||||
|                     f"Waiting {RETRY_SLEEP_SECONDS}s", |                     f"Waiting {RETRY_SLEEP_SECONDS}s", | ||||||
|                     flush=True, |                     flush=True, | ||||||
|                 ) |                 ) | ||||||
|   | |||||||
| @@ -121,7 +121,7 @@ class BarcodeReader: | |||||||
|             if barcode.text: |             if barcode.text: | ||||||
|                 barcodes.append(barcode.text) |                 barcodes.append(barcode.text) | ||||||
|                 logger.debug( |                 logger.debug( | ||||||
|                     f"Barcode of type {str(barcode.format)} found: {barcode.text}", |                     f"Barcode of type {barcode.format} found: {barcode.text}", | ||||||
|                 ) |                 ) | ||||||
|  |  | ||||||
|         return barcodes |         return barcodes | ||||||
| @@ -141,7 +141,7 @@ class BarcodeReader: | |||||||
|                 decoded_barcode = barcode.data.decode("utf-8") |                 decoded_barcode = barcode.data.decode("utf-8") | ||||||
|                 barcodes.append(decoded_barcode) |                 barcodes.append(decoded_barcode) | ||||||
|                 logger.debug( |                 logger.debug( | ||||||
|                     f"Barcode of type {str(barcode.type)} found: {decoded_barcode}", |                     f"Barcode of type {barcode.type} found: {decoded_barcode}", | ||||||
|                 ) |                 ) | ||||||
|  |  | ||||||
|         return barcodes |         return barcodes | ||||||
| @@ -348,7 +348,7 @@ class BarcodeReader: | |||||||
|  |  | ||||||
|         for idx, document_path in enumerate(doc_paths): |         for idx, document_path in enumerate(doc_paths): | ||||||
|             if override_name is not None: |             if override_name is not None: | ||||||
|                 newname = f"{str(idx)}_{override_name}" |                 newname = f"{idx}_{override_name}" | ||||||
|                 dest = save_to_dir / newname |                 dest = save_to_dir / newname | ||||||
|             else: |             else: | ||||||
|                 dest = save_to_dir |                 dest = save_to_dir | ||||||
|   | |||||||
| @@ -346,7 +346,7 @@ def cleanup_document_deletion(sender, instance, using, **kwargs): | |||||||
|                     logger.debug(f"Deleted file {filename}.") |                     logger.debug(f"Deleted file {filename}.") | ||||||
|                 except OSError as e: |                 except OSError as e: | ||||||
|                     logger.warning( |                     logger.warning( | ||||||
|                         f"While deleting document {str(instance)}, the file " |                         f"While deleting document {instance!s}, the file " | ||||||
|                         f"{filename} could not be deleted: {e}", |                         f"{filename} could not be deleted: {e}", | ||||||
|                     ) |                     ) | ||||||
|  |  | ||||||
| @@ -369,13 +369,13 @@ class CannotMoveFilesException(Exception): | |||||||
| def validate_move(instance, old_path, new_path): | def validate_move(instance, old_path, new_path): | ||||||
|     if not os.path.isfile(old_path): |     if not os.path.isfile(old_path): | ||||||
|         # Can't do anything if the old file does not exist anymore. |         # Can't do anything if the old file does not exist anymore. | ||||||
|         logger.fatal(f"Document {str(instance)}: File {old_path} has gone.") |         logger.fatal(f"Document {instance!s}: File {old_path} has gone.") | ||||||
|         raise CannotMoveFilesException |         raise CannotMoveFilesException | ||||||
|  |  | ||||||
|     if os.path.isfile(new_path): |     if os.path.isfile(new_path): | ||||||
|         # Can't do anything if the new file already exists. Skip updating file. |         # Can't do anything if the new file already exists. Skip updating file. | ||||||
|         logger.warning( |         logger.warning( | ||||||
|             f"Document {str(instance)}: Cannot rename file " |             f"Document {instance!s}: Cannot rename file " | ||||||
|             f"since target path {new_path} already exists.", |             f"since target path {new_path} already exists.", | ||||||
|         ) |         ) | ||||||
|         raise CannotMoveFilesException |         raise CannotMoveFilesException | ||||||
|   | |||||||
| @@ -116,7 +116,7 @@ def consume_file( | |||||||
|                         {"type": "status_update", "data": payload}, |                         {"type": "status_update", "data": payload}, | ||||||
|                     ) |                     ) | ||||||
|                 except ConnectionError as e: |                 except ConnectionError as e: | ||||||
|                     logger.warning(f"ConnectionError on status send: {str(e)}") |                     logger.warning(f"ConnectionError on status send: {e!s}") | ||||||
|                 # consuming stops here, since the original document with |                 # consuming stops here, since the original document with | ||||||
|                 # the barcodes has been split and will be consumed separately |                 # the barcodes has been split and will be consumed separately | ||||||
|  |  | ||||||
|   | |||||||
| @@ -519,7 +519,7 @@ class DocumentViewSet( | |||||||
|             try: |             try: | ||||||
|                 return Response(self.getNotes(doc)) |                 return Response(self.getNotes(doc)) | ||||||
|             except Exception as e: |             except Exception as e: | ||||||
|                 logger.warning(f"An error occurred retrieving notes: {str(e)}") |                 logger.warning(f"An error occurred retrieving notes: {e!s}") | ||||||
|                 return Response( |                 return Response( | ||||||
|                     {"error": "Error retreiving notes, check logs for more detail."}, |                     {"error": "Error retreiving notes, check logs for more detail."}, | ||||||
|                 ) |                 ) | ||||||
| @@ -538,7 +538,7 @@ class DocumentViewSet( | |||||||
|  |  | ||||||
|                 return Response(self.getNotes(doc)) |                 return Response(self.getNotes(doc)) | ||||||
|             except Exception as e: |             except Exception as e: | ||||||
|                 logger.warning(f"An error occurred saving note: {str(e)}") |                 logger.warning(f"An error occurred saving note: {e!s}") | ||||||
|                 return Response( |                 return Response( | ||||||
|                     { |                     { | ||||||
|                         "error": "Error saving note, check logs for more detail.", |                         "error": "Error saving note, check logs for more detail.", | ||||||
| @@ -628,7 +628,7 @@ class UnifiedSearchViewSet(DocumentViewSet): | |||||||
|             except NotFound: |             except NotFound: | ||||||
|                 raise |                 raise | ||||||
|             except Exception as e: |             except Exception as e: | ||||||
|                 logger.warning(f"An error occurred listing search results: {str(e)}") |                 logger.warning(f"An error occurred listing search results: {e!s}") | ||||||
|                 return HttpResponseBadRequest( |                 return HttpResponseBadRequest( | ||||||
|                     "Error listing search results, check logs for more detail.", |                     "Error listing search results, check logs for more detail.", | ||||||
|                 ) |                 ) | ||||||
| @@ -699,7 +699,7 @@ class BulkEditView(GenericAPIView): | |||||||
|             result = method(documents, **parameters) |             result = method(documents, **parameters) | ||||||
|             return Response({"result": result}) |             return Response({"result": result}) | ||||||
|         except Exception as e: |         except Exception as e: | ||||||
|             logger.warning(f"An error occurred performing bulk edit: {str(e)}") |             logger.warning(f"An error occurred performing bulk edit: {e!s}") | ||||||
|             return HttpResponseBadRequest( |             return HttpResponseBadRequest( | ||||||
|                 "Error performing bulk edit, check logs for more detail.", |                 "Error performing bulk edit, check logs for more detail.", | ||||||
|             ) |             ) | ||||||
|   | |||||||
| @@ -544,7 +544,7 @@ class MailAccountHandler(LoggingMixin): | |||||||
|         criterias = make_criterias(rule, supports_gmail_labels) |         criterias = make_criterias(rule, supports_gmail_labels) | ||||||
|  |  | ||||||
|         self.log.debug( |         self.log.debug( | ||||||
|             f"Rule {rule}: Searching folder with criteria {str(criterias)}", |             f"Rule {rule}: Searching folder with criteria {criterias}", | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|         try: |         try: | ||||||
|   | |||||||
| @@ -335,7 +335,7 @@ class RasterisedDocumentParser(DocumentParser): | |||||||
|                 self.text = text_original |                 self.text = text_original | ||||||
|         except (NoTextFoundException, InputFileError) as e: |         except (NoTextFoundException, InputFileError) as e: | ||||||
|             self.log.warning( |             self.log.warning( | ||||||
|                 f"Encountered an error while running OCR: {str(e)}. " |                 f"Encountered an error while running OCR: {e!s}. " | ||||||
|                 f"Attempting force OCR to get the text.", |                 f"Attempting force OCR to get the text.", | ||||||
|             ) |             ) | ||||||
|  |  | ||||||
| @@ -370,11 +370,11 @@ class RasterisedDocumentParser(DocumentParser): | |||||||
|  |  | ||||||
|             except Exception as e: |             except Exception as e: | ||||||
|                 # If this fails, we have a serious issue at hand. |                 # If this fails, we have a serious issue at hand. | ||||||
|                 raise ParseError(f"{e.__class__.__name__}: {str(e)}") from e |                 raise ParseError(f"{e.__class__.__name__}: {e!s}") from e | ||||||
|  |  | ||||||
|         except Exception as e: |         except Exception as e: | ||||||
|             # Anything else is probably serious. |             # Anything else is probably serious. | ||||||
|             raise ParseError(f"{e.__class__.__name__}: {str(e)}") from e |             raise ParseError(f"{e.__class__.__name__}: {e!s}") from e | ||||||
|  |  | ||||||
|         # As a last resort, if we still don't have any text for any reason, |         # As a last resort, if we still don't have any text for any reason, | ||||||
|         # try to extract the text from the original document. |         # try to extract the text from the original document. | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Trenton H
					Trenton H