mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-31 13:15:43 +00:00 
			
		
		
		
	Add flake8-logging linting (#5620)
* added flake8-logging to make logging more robust * fixed LOG005 warnings * fixed LOG008 warnings * fixed LOG011 warnings * fixed more LOG011 errors * added ignores for intentional logger.error calls * fixed even more LOG011 errors
This commit is contained in:
		| @@ -1164,13 +1164,13 @@ class Build(MPTTModel, InvenTree.models.InvenTreeBarcodeMixin, InvenTree.models. | ||||
|  | ||||
|         bom_items = self.part.get_bom_items() | ||||
|  | ||||
|         logger.info(f"Creating BuildLine objects for BuildOrder {self.pk} ({len(bom_items)} items))") | ||||
|         logger.info("Creating BuildLine objects for BuildOrder %s (%s items)", self.pk, len(bom_items)) | ||||
|  | ||||
|         # Iterate through each part required to build the parent part | ||||
|         for bom_item in bom_items: | ||||
|             if prevent_duplicates: | ||||
|                 if BuildLine.objects.filter(build=self, bom_item=bom_item).exists(): | ||||
|                     logger.info(f"BuildLine already exists for BuildOrder {self.pk} and BomItem {bom_item.pk}") | ||||
|                     logger.info("BuildLine already exists for BuildOrder %s and BomItem %s", self.pk, bom_item.pk) | ||||
|                     continue | ||||
|  | ||||
|             # Calculate required quantity | ||||
| @@ -1187,7 +1187,7 @@ class Build(MPTTModel, InvenTree.models.InvenTreeBarcodeMixin, InvenTree.models. | ||||
|         BuildLine.objects.bulk_create(lines) | ||||
|  | ||||
|         if len(lines) > 0: | ||||
|             logger.info(f"Created {len(lines)} BuildLine objects for BuildOrder") | ||||
|             logger.info("Created %s BuildLine objects for BuildOrder", len(lines)) | ||||
|  | ||||
|     @transaction.atomic | ||||
|     def update_build_line_items(self): | ||||
| @@ -1201,7 +1201,7 @@ class Build(MPTTModel, InvenTree.models.InvenTreeBarcodeMixin, InvenTree.models. | ||||
|  | ||||
|         BuildLine.objects.bulk_update(lines_to_update, ['quantity']) | ||||
|  | ||||
|         logger.info(f"Updated {len(lines_to_update)} BuildLine objects for BuildOrder") | ||||
|         logger.info("Updated %s BuildLine objects for BuildOrder", len(lines_to_update)) | ||||
|  | ||||
|  | ||||
| @receiver(post_save, sender=Build, dispatch_uid='build_post_save_log') | ||||
|   | ||||
| @@ -30,7 +30,7 @@ def update_build_order_lines(bom_item_pk: int): | ||||
|     This task is triggered when a BomItem is created or updated. | ||||
|     """ | ||||
|  | ||||
|     logger.info(f"Updating build order lines for BomItem {bom_item_pk}") | ||||
|     logger.info("Updating build order lines for BomItem %s", bom_item_pk) | ||||
|  | ||||
|     bom_item = part_models.BomItem.objects.filter(pk=bom_item_pk).first() | ||||
|  | ||||
| @@ -70,7 +70,7 @@ def update_build_order_lines(bom_item_pk: int): | ||||
|             ) | ||||
|  | ||||
|     if builds.count() > 0: | ||||
|         logger.info(f"Updated {builds.count()} build orders for part {bom_item.part}") | ||||
|         logger.info("Updated %s build orders for part %s", builds.count(), bom_item.part) | ||||
|  | ||||
|  | ||||
| def check_build_stock(build: build.models.Build): | ||||
| @@ -94,7 +94,7 @@ def check_build_stock(build: build.models.Build): | ||||
|         part = build.part | ||||
|     except part_models.Part.DoesNotExist: | ||||
|         # Note: This error may be thrown during unit testing... | ||||
|         logger.error("Invalid build.part passed to 'build.tasks.check_build_stock'") | ||||
|         logger.exception("Invalid build.part passed to 'build.tasks.check_build_stock'") | ||||
|         return | ||||
|  | ||||
|     for bom_item in part.get_bom_items(): | ||||
| @@ -135,7 +135,7 @@ def check_build_stock(build: build.models.Build): | ||||
|  | ||||
|     if len(emails) > 0: | ||||
|  | ||||
|         logger.info(f"Notifying users of stock required for build {build.pk}") | ||||
|         logger.info("Notifying users of stock required for build %s", build.pk) | ||||
|  | ||||
|         context = { | ||||
|             'link': InvenTree.helpers_model.construct_absolute_url(build.get_absolute_url()), | ||||
|   | ||||
		Reference in New Issue
	
	Block a user