Fix pre-commit complaints (#3349)

* fixes a B023 error by refactoring the function call

* restructure for correct lambda
This commit is contained in:
Matthias Mair 2022-07-18 00:57:14 +02:00 committed by GitHub
parent d5014ab6ac
commit 6aeb818137
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -813,6 +813,14 @@ class Build(MPTTModel, ReferenceIndexingMixin):
interchangeable = kwargs.get('interchangeable', False)
substitutes = kwargs.get('substitutes', True)
def stock_sort(item, bom_item, variant_parts):
if item.part == bom_item.sub_part:
return 1
elif item.part in variant_parts:
return 2
else:
return 3
# Get a list of all 'untracked' BOM items
for bom_item in self.untracked_bom_items:
@ -859,15 +867,7 @@ class Build(MPTTModel, ReferenceIndexingMixin):
This ensures that allocation priority is first given to "direct" parts
"""
def stock_sort(item):
if item.part == bom_item.sub_part:
return 1
elif item.part in variant_parts:
return 2
else:
return 3
available_stock = sorted(available_stock, key=stock_sort)
available_stock = sorted(available_stock, key=lambda item, b=bom_item, v=variant_parts: stock_sort(item, b, v))
if len(available_stock) == 0:
# No stock items are available