2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-01 03:00:54 +00:00

Code style improvements (#4683)

* fix list comps

* mopre comp fixes

* reduce computing cost on any() calls

* add bugbear

* check for clean imports

* only allow limited relative imports

* fix notification method lookup

* fix notification method assigement

* rewrite assigment

* fix upstream changes to new style

* fix upstream change to new coding style
This commit is contained in:
Matthias Mair
2023-04-28 12:49:53 +02:00
committed by GitHub
parent 660a4f8e39
commit abee2cee88
44 changed files with 96 additions and 93 deletions

View File

@ -3,7 +3,7 @@
from django.contrib import admin
from django.utils.translation import gettext_lazy as _
import import_export.widgets as widgets
from import_export import widgets
from import_export.admin import ImportExportModelAdmin
from import_export.fields import Field

View File

@ -1118,7 +1118,7 @@ class StockItemTestResultList(ListCreateDestroyAPIView):
# Note that this function is recursive!
installed_items = item.get_installed_items(cascade=True)
items += [it for it in installed_items]
items += list(installed_items)
queryset = queryset.filter(stock_item__in=items)

View File

@ -71,14 +71,15 @@ class StockLocation(InvenTreeBarcodeMixin, MetadataMixin, InvenTreeTree):
for child_location in self.children.all():
if kwargs.get('delete_sub_locations', False):
child_location.delete_recursive(**dict(delete_sub_locations=True,
delete_stock_items=delete_stock_items,
parent_location=parent_location))
child_location.delete_recursive(**{
"delete_sub_locations": True,
"delete_stock_items": delete_stock_items,
"parent_location": parent_location})
else:
child_location.parent = parent_location
child_location.save()
super().delete(*args, **dict())
super().delete(*args, **{})
def delete(self, *args, **kwargs):
"""Custom model deletion routine, which updates any child locations or items.
@ -87,9 +88,10 @@ class StockLocation(InvenTreeBarcodeMixin, MetadataMixin, InvenTreeTree):
"""
with transaction.atomic():
self.delete_recursive(**dict(delete_stock_items=kwargs.get('delete_stock_items', False),
delete_sub_locations=kwargs.get('delete_sub_locations', False),
parent_category=self.parent))
self.delete_recursive(**{
"delete_stock_items": kwargs.get('delete_stock_items', False),
"delete_sub_locations": kwargs.get('delete_sub_locations', False),
"parent_category": self.parent})
if self.parent is not None:
# Partially rebuild the tree (cheaper than a complete rebuild)

View File

@ -110,7 +110,7 @@ class TestScheduledForDeletionMigration(MigratorTestCase):
scheduled_for_deletion=True,
)
for ii in range(3):
for _ in range(3):
StockItem.objects.create(
part=part,
quantity=200,