mirror of
https://github.com/inventree/InvenTree.git
synced 2026-05-23 09:35:30 +00:00
Add more checks to pre-commit (#3132)
* Add bandit to pre-commit checks * fix catchall exceptions * remove unused definitons * remove unuseed ariables * Add docstring * fix B006, B008 errors * fix B007 error * ignore B009 * Add checks for formatting and naming
This commit is contained in:
+10
-10
@@ -99,7 +99,7 @@ class StockItemContextMixin:
|
||||
|
||||
try:
|
||||
context['item'] = StockItem.objects.get(pk=self.kwargs.get('pk', None))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
return context
|
||||
@@ -830,7 +830,7 @@ class StockList(APIDownloadMixin, generics.ListCreateAPIView):
|
||||
|
||||
if part.tree_id is not None:
|
||||
queryset = queryset.filter(part__tree_id=part.tree_id)
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Filter by 'allocated' parts?
|
||||
@@ -1144,7 +1144,7 @@ class StockItemTestResultList(generics.ListCreateAPIView):
|
||||
"""Set context before returning serializer."""
|
||||
try:
|
||||
kwargs['user_detail'] = str2bool(self.request.query_params.get('user_detail', False))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
kwargs['context'] = self.get_serializer_context()
|
||||
@@ -1186,12 +1186,12 @@ class StockTrackingList(generics.ListAPIView):
|
||||
"""Set context before returning serializer."""
|
||||
try:
|
||||
kwargs['item_detail'] = str2bool(self.request.query_params.get('item_detail', False))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
kwargs['user_detail'] = str2bool(self.request.query_params.get('user_detail', False))
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
kwargs['context'] = self.get_serializer_context()
|
||||
@@ -1219,7 +1219,7 @@ class StockTrackingList(generics.ListAPIView):
|
||||
part = Part.objects.get(pk=deltas['part'])
|
||||
serializer = PartBriefSerializer(part)
|
||||
deltas['part_detail'] = serializer.data
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Add location detail
|
||||
@@ -1228,7 +1228,7 @@ class StockTrackingList(generics.ListAPIView):
|
||||
location = StockLocation.objects.get(pk=deltas['location'])
|
||||
serializer = StockSerializers.LocationSerializer(location)
|
||||
deltas['location_detail'] = serializer.data
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Add stockitem detail
|
||||
@@ -1237,7 +1237,7 @@ class StockTrackingList(generics.ListAPIView):
|
||||
stockitem = StockItem.objects.get(pk=deltas['stockitem'])
|
||||
serializer = StockSerializers.StockItemSerializer(stockitem)
|
||||
deltas['stockitem_detail'] = serializer.data
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Add customer detail
|
||||
@@ -1246,7 +1246,7 @@ class StockTrackingList(generics.ListAPIView):
|
||||
customer = Company.objects.get(pk=deltas['customer'])
|
||||
serializer = CompanySerializer(customer)
|
||||
deltas['customer_detail'] = serializer.data
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Add purchaseorder detail
|
||||
@@ -1255,7 +1255,7 @@ class StockTrackingList(generics.ListAPIView):
|
||||
order = PurchaseOrder.objects.get(pk=deltas['purchaseorder'])
|
||||
serializer = PurchaseOrderSerializer(order)
|
||||
deltas['purchaseorder_detail'] = serializer.data
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if request.is_ajax():
|
||||
|
||||
Reference in New Issue
Block a user