mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
upgrade to pyhton 3.9 syntax
using pyupgrade
This commit is contained in:
parent
b59a4d53f0
commit
d05472b30c
@ -319,7 +319,7 @@ class CustomSocialAccountAdapter(RegistratonMixin, DefaultSocialAccountAdapter):
|
|||||||
redirect_url = reverse('two-factor-authenticate')
|
redirect_url = reverse('two-factor-authenticate')
|
||||||
# Add GET parameters to the URL if they exist.
|
# Add GET parameters to the URL if they exist.
|
||||||
if request.GET:
|
if request.GET:
|
||||||
redirect_url += u'?' + urlencode(request.GET)
|
redirect_url += '?' + urlencode(request.GET)
|
||||||
|
|
||||||
raise ImmediateHttpResponse(
|
raise ImmediateHttpResponse(
|
||||||
response=HttpResponseRedirect(redirect_url)
|
response=HttpResponseRedirect(redirect_url)
|
||||||
|
@ -432,7 +432,7 @@ def extract_serial_numbers(serials, expected_quantity, next_number: int):
|
|||||||
next_number += 1
|
next_number += 1
|
||||||
|
|
||||||
# Split input string by whitespace or comma (,) characters
|
# Split input string by whitespace or comma (,) characters
|
||||||
groups = re.split("[\s,]+", serials)
|
groups = re.split(r"[\s,]+", serials)
|
||||||
|
|
||||||
numbers = []
|
numbers = []
|
||||||
errors = []
|
errors = []
|
||||||
|
@ -85,7 +85,7 @@ class AuthRequiredMiddleware(object):
|
|||||||
if path not in urls and not path.startswith('/api/'):
|
if path not in urls and not path.startswith('/api/'):
|
||||||
# Save the 'next' parameter to pass through to the login view
|
# 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)
|
response = self.get_response(request)
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
from test.support import EnvironmentVarGuard
|
from test.support import EnvironmentVarGuard
|
||||||
|
|
||||||
@ -186,7 +185,7 @@ class TestDownloadFile(TestCase):
|
|||||||
|
|
||||||
def test_download(self):
|
def test_download(self):
|
||||||
helpers.DownloadFile("hello world", "out.txt")
|
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):
|
class TestMPTT(TestCase):
|
||||||
|
@ -53,7 +53,7 @@ def get_next_build_number():
|
|||||||
|
|
||||||
build = Build.objects.exclude(reference=None).last()
|
build = Build.objects.exclude(reference=None).last()
|
||||||
|
|
||||||
attempts = set([build.reference])
|
attempts = {build.reference}
|
||||||
|
|
||||||
reference = build.reference
|
reference = build.reference
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ def calculate_shipped_quantity(apps, schema_editor):
|
|||||||
part=item.part
|
part=item.part
|
||||||
)
|
)
|
||||||
|
|
||||||
q = sum([item.quantity for item in items])
|
q = sum(item.quantity for item in items)
|
||||||
|
|
||||||
item.shipped = q
|
item.shipped = q
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ def get_next_po_number():
|
|||||||
|
|
||||||
order = PurchaseOrder.objects.exclude(reference=None).last()
|
order = PurchaseOrder.objects.exclude(reference=None).last()
|
||||||
|
|
||||||
attempts = set([order.reference])
|
attempts = {order.reference}
|
||||||
|
|
||||||
reference = order.reference
|
reference = order.reference
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ def get_next_so_number():
|
|||||||
|
|
||||||
order = SalesOrder.objects.exclude(reference=None).last()
|
order = SalesOrder.objects.exclude(reference=None).last()
|
||||||
|
|
||||||
attempts = set([order.reference])
|
attempts = {order.reference}
|
||||||
|
|
||||||
reference = order.reference
|
reference = order.reference
|
||||||
|
|
||||||
@ -161,10 +161,10 @@ class Order(ReferenceIndexingMixin):
|
|||||||
# gather name reference
|
# gather name reference
|
||||||
price_ref = 'sale_price' if isinstance(self, SalesOrder) else 'purchase_price'
|
price_ref = 'sale_price' if isinstance(self, SalesOrder) else 'purchase_price'
|
||||||
# order items
|
# 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
|
# 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
|
# set decimal-places
|
||||||
total.decimal_places = 4
|
total.decimal_places = 4
|
||||||
|
@ -2510,7 +2510,7 @@ def validate_template_name(name):
|
|||||||
Prevent illegal characters in "name" field for PartParameterTemplate
|
Prevent illegal characters in "name" field for PartParameterTemplate
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for c in "!@#$%^&*()<>{}[].,?/\|~`_+-=\'\"":
|
for c in "!@#$%^&*()<>{}[].,?/\\|~`_+-=\'\"":
|
||||||
if c in str(name):
|
if c in str(name):
|
||||||
raise ValidationError(_(f"Illegal character in template name ({c})"))
|
raise ValidationError(_(f"Illegal character in template name ({c})"))
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ def update_history(apps, schema_editor):
|
|||||||
tracking_type = StockHistoryCode.STOCK_REMOVE
|
tracking_type = StockHistoryCode.STOCK_REMOVE
|
||||||
|
|
||||||
# Extract the number of removed items
|
# Extract the number of removed items
|
||||||
result = re.search("^removed ([\d\.]+) items", title)
|
result = re.search(r"^removed ([\d\.]+) items", title)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
|
|
||||||
@ -102,7 +102,7 @@ def update_history(apps, schema_editor):
|
|||||||
elif 'moved to' in title:
|
elif 'moved to' in title:
|
||||||
tracking_type = StockHistoryCode.STOCK_MOVE
|
tracking_type = StockHistoryCode.STOCK_MOVE
|
||||||
|
|
||||||
result = re.search('^Moved to (.*)( - )*(.*) \(from.*$', entry.title)
|
result = re.search(r'^Moved to (.*)( - )*(.*) \(from.*$', entry.title)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
# Legacy tracking entries recorded the location in multiple ways, because.. why not?
|
# 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
|
tracking_type = StockHistoryCode.STOCK_ADD
|
||||||
|
|
||||||
# Extract the number of added items
|
# Extract the number of added items
|
||||||
result = re.search("^added ([\d\.]+) items", title)
|
result = re.search(r"^added ([\d\.]+) items", title)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
print("Checking development branch")
|
print("Checking development branch")
|
||||||
|
|
||||||
pattern = "^\d+(\.\d+)+ dev$"
|
pattern = r"^\d+(\.\d+)+ dev$"
|
||||||
|
|
||||||
result = re.match(pattern, version)
|
result = re.match(pattern, version)
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
print("Checking release branch")
|
print("Checking release branch")
|
||||||
|
|
||||||
pattern = "^\d+(\.\d+)+$"
|
pattern = r"^\d+(\.\d+)+$"
|
||||||
|
|
||||||
result = re.match(pattern, version)
|
result = re.match(pattern, version)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user