2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-18 04:55:44 +00:00
* bump deps

* use isinstance where possible

* and another bump ;-)

* small fix for isinstance

* fixed wrong comparison

* fixed comparision

* use exact comparision
This commit is contained in:
Matthias Mair
2023-08-06 13:39:15 +02:00
committed by GitHub
parent 54e0e47c6a
commit 879d496e26
11 changed files with 31 additions and 31 deletions

View File

@ -45,7 +45,7 @@ def to_dict(value):
if value is None:
return {}
if type(value) == dict:
if isinstance(value, dict):
return value
try:

View File

@ -53,7 +53,7 @@ def is_email_configured():
def send_email(subject, body, recipients, from_email=None, html_message=None):
"""Send an email with the specified subject and body, to the specified recipients list."""
if type(recipients) == str:
if isinstance(recipients, str):
recipients = [recipients]
import InvenTree.ready

View File

@ -387,13 +387,13 @@ def DownloadFile(data, filename, content_type='application/text', inline=False)
filename = WrapWithQuotes(filename)
length = len(data)
if type(data) == str:
if isinstance(data, str):
wrapper = FileWrapper(io.StringIO(data))
else:
wrapper = FileWrapper(io.BytesIO(data))
response = StreamingHttpResponse(wrapper, content_type=content_type)
if type(data) == str:
if isinstance(data, str):
length = len(bytes(data, response.charset))
response['Content-Length'] = length

View File

@ -57,7 +57,7 @@ def sanitize_svg(file_data, strip: bool = True, elements: str = ALLOWED_ELEMENTS
"""
# Handle byte-encoded data
if type(file_data) == bytes:
if isinstance(file_data, bytes):
file_data = file_data.decode('utf-8')
cleaned = clean(

View File

@ -17,13 +17,13 @@ class BaseEnum(enum.IntEnum):
def __eq__(self, obj):
"""Override equality operator to allow comparison with int."""
if type(self) == type(obj):
if type(self) is type(obj):
return super().__eq__(obj)
return self.value == obj
def __ne__(self, obj):
"""Override inequality operator to allow comparison with int."""
if type(self) == type(obj):
if type(self) is type(obj):
return super().__ne__(obj)
return self.value != obj
@ -70,7 +70,7 @@ class StatusCode(BaseEnum):
return False
if callable(value):
return False
if type(value.value) != int:
if not isinstance(value.value, int):
return False
return True

View File

@ -1878,7 +1878,7 @@ class BomItemValidate(UpdateAPI):
serializer = self.get_serializer(instance, data=data, partial=partial)
serializer.is_valid(raise_exception=True)
if type(instance) == BomItem:
if isinstance(instance, BomItem):
instance.validate_hash(valid)
return Response(serializer.data)

View File

@ -55,7 +55,7 @@ def render_date(context, date_object):
if date_object is None:
return None
if type(date_object) == str:
if isinstance(date_object, str):
date_object = date_object.strip()

View File

@ -377,7 +377,7 @@ class BuildReport(ReportTemplateBase):
"""Custom context data for the build report."""
my_build = self.object_to_print
if type(my_build) != build.models.Build:
if not isinstance(my_build, build.models.Build):
raise TypeError('Provided model is not a Build object')
return {
@ -653,7 +653,7 @@ class StockLocationReport(ReportTemplateBase):
"""Return custom context data for the StockLocationReport template"""
stock_location = self.object_to_print
if type(stock_location) != stock.models.StockLocation:
if not isinstance(stock_location, stock.models.StockLocation):
raise TypeError('Provided model is not a StockLocation object -> ' + str(type(stock_location)))
return {

View File

@ -168,12 +168,12 @@ class BarcodeTagTest(TestCase):
barcode = barcode_tags.barcode("12345")
self.assertTrue(type(barcode) == str)
self.assertTrue(isinstance(barcode, str))
self.assertTrue(barcode.startswith('data:image/png;'))
# Try with a different format
barcode = barcode_tags.barcode('99999', format='BMP')
self.assertTrue(type(barcode) == str)
self.assertTrue(isinstance(barcode, str))
self.assertTrue(barcode.startswith('data:image/bmp;'))
def test_qrcode(self):
@ -181,7 +181,7 @@ class BarcodeTagTest(TestCase):
# Test with default settings
qrcode = barcode_tags.qrcode("hello world")
self.assertTrue(type(qrcode) == str)
self.assertTrue(isinstance(qrcode, str))
self.assertTrue(qrcode.startswith('data:image/png;'))
self.assertEqual(len(qrcode), 700)
@ -192,7 +192,7 @@ class BarcodeTagTest(TestCase):
box_size=50,
format='BMP',
)
self.assertTrue(type(qrcode) == str)
self.assertTrue(isinstance(qrcode, str))
self.assertTrue(qrcode.startswith('data:image/bmp;'))
self.assertEqual(len(qrcode), 309720)