From 879d496e26c17f4d9a9340d3c028b369534ea9ef Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Sun, 6 Aug 2023 13:39:15 +0200 Subject: [PATCH] Bump deps (#5385) * bump deps * use isinstance where possible * and another bump ;-) * small fix for isinstance * fixed wrong comparison * fixed comparision * use exact comparision --- InvenTree/InvenTree/config.py | 2 +- InvenTree/InvenTree/email.py | 2 +- InvenTree/InvenTree/helpers.py | 4 ++-- InvenTree/InvenTree/sanitizer.py | 2 +- InvenTree/generic/states/states.py | 6 +++--- InvenTree/part/api.py | 2 +- InvenTree/part/templatetags/inventree_extras.py | 2 +- InvenTree/report/models.py | 4 ++-- InvenTree/report/tests.py | 8 ++++---- requirements-dev.txt | 14 +++++++------- requirements.txt | 16 ++++++++-------- 11 files changed, 31 insertions(+), 31 deletions(-) diff --git a/InvenTree/InvenTree/config.py b/InvenTree/InvenTree/config.py index 3657d0c530..1ddbc80d6c 100644 --- a/InvenTree/InvenTree/config.py +++ b/InvenTree/InvenTree/config.py @@ -45,7 +45,7 @@ def to_dict(value): if value is None: return {} - if type(value) == dict: + if isinstance(value, dict): return value try: diff --git a/InvenTree/InvenTree/email.py b/InvenTree/InvenTree/email.py index 0d2b446a58..c2371edfa3 100644 --- a/InvenTree/InvenTree/email.py +++ b/InvenTree/InvenTree/email.py @@ -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 diff --git a/InvenTree/InvenTree/helpers.py b/InvenTree/InvenTree/helpers.py index 45b1294b43..84aab20c04 100644 --- a/InvenTree/InvenTree/helpers.py +++ b/InvenTree/InvenTree/helpers.py @@ -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 diff --git a/InvenTree/InvenTree/sanitizer.py b/InvenTree/InvenTree/sanitizer.py index d417b85118..2016954de1 100644 --- a/InvenTree/InvenTree/sanitizer.py +++ b/InvenTree/InvenTree/sanitizer.py @@ -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( diff --git a/InvenTree/generic/states/states.py b/InvenTree/generic/states/states.py index f53b008ea1..06aa45ba22 100644 --- a/InvenTree/generic/states/states.py +++ b/InvenTree/generic/states/states.py @@ -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 diff --git a/InvenTree/part/api.py b/InvenTree/part/api.py index d88791df09..60f371af56 100644 --- a/InvenTree/part/api.py +++ b/InvenTree/part/api.py @@ -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) diff --git a/InvenTree/part/templatetags/inventree_extras.py b/InvenTree/part/templatetags/inventree_extras.py index 8c2fe6f084..b908d59037 100644 --- a/InvenTree/part/templatetags/inventree_extras.py +++ b/InvenTree/part/templatetags/inventree_extras.py @@ -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() diff --git a/InvenTree/report/models.py b/InvenTree/report/models.py index 8d32096872..2104b73476 100644 --- a/InvenTree/report/models.py +++ b/InvenTree/report/models.py @@ -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 { diff --git a/InvenTree/report/tests.py b/InvenTree/report/tests.py index f97490e228..321e323c91 100644 --- a/InvenTree/report/tests.py +++ b/InvenTree/report/tests.py @@ -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) diff --git a/requirements-dev.txt b/requirements-dev.txt index 67c1916f3f..1b0caabf21 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -45,7 +45,7 @@ docopt==0.6.2 # via coveralls filelock==3.12.2 # via virtualenv -flake8==6.0.0 +flake8==6.1.0 # via # -r requirements-dev.in # flake8-docstrings @@ -70,17 +70,17 @@ packaging==23.1 # build pep8-naming==0.13.3 # via -r requirements-dev.in -pip-tools==7.1.0 +pip-tools==7.2.0 # via -r requirements-dev.in -platformdirs==3.9.1 +platformdirs==3.10.0 # via virtualenv pre-commit==3.3.3 # via -r requirements-dev.in -pycodestyle==2.10.0 +pycodestyle==2.11.0 # via flake8 pydocstyle==6.3.0 # via flake8-docstrings -pyflakes==3.0.1 +pyflakes==3.1.0 # via flake8 pyproject-hooks==1.0.0 # via build @@ -117,9 +117,9 @@ urllib3==2.0.4 # via # -c requirements.txt # requests -virtualenv==20.24.1 +virtualenv==20.24.2 # via pre-commit -wheel==0.41.0 +wheel==0.41.1 # via pip-tools # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements.txt b/requirements.txt index 2bfef02263..28536bab2c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -32,7 +32,7 @@ coreapi==2.3.3 # via -r requirements.in coreschema==0.0.4 # via coreapi -cryptography==41.0.2 +cryptography==41.0.3 # via # -r requirements.in # djangorestframework-simplejwt @@ -129,7 +129,7 @@ django-recurrence==1.11.1 # via django-ical django-redis==5.3.0 # via -r requirements.in -django-sesame==3.1 +django-sesame==3.2 # via -r requirements.in django-sql-utils==0.6.1 # via -r requirements.in @@ -153,7 +153,7 @@ djangorestframework==3.14.0 # drf-spectacular djangorestframework-simplejwt[crypto]==5.2.2 # via -r requirements.in -drf-spectacular==0.26.3 +drf-spectacular==0.26.4 # via -r requirements.in dulwich==0.21.5 # via -r requirements.in @@ -161,7 +161,7 @@ et-xmlfile==1.1.0 # via openpyxl feedparser==6.0.10 # via -r requirements.in -fonttools[woff]==4.41.1 +fonttools[woff]==4.42.0 # via weasyprint gunicorn==21.2.0 # via -r requirements.in @@ -179,11 +179,11 @@ itypes==1.2.0 # via coreapi jinja2==3.1.2 # via coreschema -jsonschema==4.18.4 +jsonschema==4.18.6 # via drf-spectacular jsonschema-specifications==2023.7.1 # via jsonschema -markdown==3.4.3 +markdown==3.4.4 # via django-markdownify markuppy==1.14 # via tablib @@ -256,7 +256,7 @@ rapidfuzz==0.7.6 # via -r requirements.in redis==4.6.0 # via django-redis -referencing==0.30.0 +referencing==0.30.2 # via # jsonschema # jsonschema-specifications @@ -273,7 +273,7 @@ rpds-py==0.9.2 # via # jsonschema # referencing -sentry-sdk==1.28.1 +sentry-sdk==1.29.2 # via # -r requirements.in # django-q-sentry