diff --git a/InvenTree/InvenTree/forms.py b/InvenTree/InvenTree/forms.py index 91863f04e2..dd40e54d9c 100644 --- a/InvenTree/InvenTree/forms.py +++ b/InvenTree/InvenTree/forms.py @@ -319,7 +319,7 @@ class CustomSocialAccountAdapter(RegistratonMixin, DefaultSocialAccountAdapter): redirect_url = reverse('two-factor-authenticate') # Add GET parameters to the URL if they exist. if request.GET: - redirect_url += u'?' + urlencode(request.GET) + redirect_url += '?' + urlencode(request.GET) raise ImmediateHttpResponse( response=HttpResponseRedirect(redirect_url) diff --git a/InvenTree/InvenTree/helpers.py b/InvenTree/InvenTree/helpers.py index 7bd4fd819d..1258fffe61 100644 --- a/InvenTree/InvenTree/helpers.py +++ b/InvenTree/InvenTree/helpers.py @@ -432,7 +432,7 @@ def extract_serial_numbers(serials, expected_quantity, next_number: int): next_number += 1 # Split input string by whitespace or comma (,) characters - groups = re.split("[\s,]+", serials) + groups = re.split(r"[\s,]+", serials) numbers = [] errors = [] diff --git a/InvenTree/InvenTree/middleware.py b/InvenTree/InvenTree/middleware.py index b43720b8bc..0ec1d4e6c5 100644 --- a/InvenTree/InvenTree/middleware.py +++ b/InvenTree/InvenTree/middleware.py @@ -85,7 +85,7 @@ class AuthRequiredMiddleware(object): if path not in urls and not path.startswith('/api/'): # Save the 'next' parameter to pass through to the login view - return redirect('%s?next=%s' % (reverse_lazy('account_login'), request.path)) + return redirect('{}?next={}'.format(reverse_lazy('account_login'), request.path)) response = self.get_response(request) diff --git a/InvenTree/InvenTree/tests.py b/InvenTree/InvenTree/tests.py index 13f9198d92..dc3aff85e6 100644 --- a/InvenTree/InvenTree/tests.py +++ b/InvenTree/InvenTree/tests.py @@ -1,4 +1,3 @@ - import json from test.support import EnvironmentVarGuard @@ -186,7 +185,7 @@ class TestDownloadFile(TestCase): def test_download(self): helpers.DownloadFile("hello world", "out.txt") - helpers.DownloadFile(bytes("hello world".encode("utf8")), "out.bin") + helpers.DownloadFile(bytes(b"hello world"), "out.bin") class TestMPTT(TestCase): diff --git a/InvenTree/build/models.py b/InvenTree/build/models.py index 86bb256539..3edced5ffe 100644 --- a/InvenTree/build/models.py +++ b/InvenTree/build/models.py @@ -53,7 +53,7 @@ def get_next_build_number(): build = Build.objects.exclude(reference=None).last() - attempts = set([build.reference]) + attempts = {build.reference} reference = build.reference diff --git a/InvenTree/common/test_tasks.py b/InvenTree/common/test_tasks.py index 4a3da9c028..3f85316c41 100644 --- a/InvenTree/common/test_tasks.py +++ b/InvenTree/common/test_tasks.py @@ -1,4 +1,3 @@ - # -*- coding: utf-8 -*- from django.test import TestCase diff --git a/InvenTree/order/migrations/0058_auto_20211126_1210.py b/InvenTree/order/migrations/0058_auto_20211126_1210.py index a1836ff380..6ba2430af9 100644 --- a/InvenTree/order/migrations/0058_auto_20211126_1210.py +++ b/InvenTree/order/migrations/0058_auto_20211126_1210.py @@ -33,7 +33,7 @@ def calculate_shipped_quantity(apps, schema_editor): part=item.part ) - q = sum([item.quantity for item in items]) + q = sum(item.quantity for item in items) item.shipped = q diff --git a/InvenTree/order/models.py b/InvenTree/order/models.py index c9147bac20..63862078f6 100644 --- a/InvenTree/order/models.py +++ b/InvenTree/order/models.py @@ -49,7 +49,7 @@ def get_next_po_number(): order = PurchaseOrder.objects.exclude(reference=None).last() - attempts = set([order.reference]) + attempts = {order.reference} reference = order.reference @@ -78,7 +78,7 @@ def get_next_so_number(): order = SalesOrder.objects.exclude(reference=None).last() - attempts = set([order.reference]) + attempts = {order.reference} reference = order.reference @@ -161,10 +161,10 @@ class Order(ReferenceIndexingMixin): # gather name reference price_ref = 'sale_price' if isinstance(self, SalesOrder) else 'purchase_price' # order items - total += sum([a.quantity * convert_money(getattr(a, price_ref), target_currency) for a in self.lines.all() if getattr(a, price_ref)]) + total += sum(a.quantity * convert_money(getattr(a, price_ref), target_currency) for a in self.lines.all() if getattr(a, price_ref)) # extra lines - total += sum([a.quantity * convert_money(a.price, target_currency) for a in self.extra_lines.all() if a.price]) + total += sum(a.quantity * convert_money(a.price, target_currency) for a in self.extra_lines.all() if a.price) # set decimal-places total.decimal_places = 4 diff --git a/InvenTree/part/models.py b/InvenTree/part/models.py index 365ed62914..46b2154c43 100644 --- a/InvenTree/part/models.py +++ b/InvenTree/part/models.py @@ -2510,7 +2510,7 @@ def validate_template_name(name): Prevent illegal characters in "name" field for PartParameterTemplate """ - for c in "!@#$%^&*()<>{}[].,?/\|~`_+-=\'\"": + for c in "!@#$%^&*()<>{}[].,?/\\|~`_+-=\'\"": if c in str(name): raise ValidationError(_(f"Illegal character in template name ({c})")) diff --git a/InvenTree/stock/migrations/0061_auto_20210511_0911.py b/InvenTree/stock/migrations/0061_auto_20210511_0911.py index 8d7a398f04..1e20071d59 100644 --- a/InvenTree/stock/migrations/0061_auto_20210511_0911.py +++ b/InvenTree/stock/migrations/0061_auto_20210511_0911.py @@ -78,7 +78,7 @@ def update_history(apps, schema_editor): tracking_type = StockHistoryCode.STOCK_REMOVE # Extract the number of removed items - result = re.search("^removed ([\d\.]+) items", title) + result = re.search(r"^removed ([\d\.]+) items", title) if result: @@ -102,7 +102,7 @@ def update_history(apps, schema_editor): elif 'moved to' in title: tracking_type = StockHistoryCode.STOCK_MOVE - result = re.search('^Moved to (.*)( - )*(.*) \(from.*$', entry.title) + result = re.search(r'^Moved to (.*)( - )*(.*) \(from.*$', entry.title) if result: # Legacy tracking entries recorded the location in multiple ways, because.. why not? @@ -157,7 +157,7 @@ def update_history(apps, schema_editor): tracking_type = StockHistoryCode.STOCK_ADD # Extract the number of added items - result = re.search("^added ([\d\.]+) items", title) + result = re.search(r"^added ([\d\.]+) items", title) if result: diff --git a/ci/check_version_number.py b/ci/check_version_number.py index 258c8780d8..0514854407 100644 --- a/ci/check_version_number.py +++ b/ci/check_version_number.py @@ -66,7 +66,7 @@ if __name__ == '__main__': print("Checking development branch") - pattern = "^\d+(\.\d+)+ dev$" + pattern = r"^\d+(\.\d+)+ dev$" result = re.match(pattern, version) @@ -82,7 +82,7 @@ if __name__ == '__main__': print("Checking release branch") - pattern = "^\d+(\.\d+)+$" + pattern = r"^\d+(\.\d+)+$" result = re.match(pattern, version)