From af8bddf690f320ea78d2ca0a5eb9d228154ef099 Mon Sep 17 00:00:00 2001 From: Matthias Mair Date: Thu, 12 May 2022 02:30:37 +0200 Subject: [PATCH] fix boolean comp --- InvenTree/InvenTree/apps.py | 2 +- InvenTree/InvenTree/helpers.py | 6 +++--- InvenTree/InvenTree/metadata.py | 2 +- InvenTree/InvenTree/models.py | 2 +- InvenTree/InvenTree/settings.py | 2 +- InvenTree/InvenTree/tasks.py | 6 +++--- InvenTree/InvenTree/views.py | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/InvenTree/InvenTree/apps.py b/InvenTree/InvenTree/apps.py index 3531cc11d7..55a738622b 100644 --- a/InvenTree/InvenTree/apps.py +++ b/InvenTree/InvenTree/apps.py @@ -131,7 +131,7 @@ class InvenTreeConfig(AppConfig): update = True # Backend currency has changed? - if not base_currency == backend.base_currency: + if base_currency != backend.base_currency: logger.info(f"Base currency changed from {backend.base_currency} to {base_currency}") update = True diff --git a/InvenTree/InvenTree/helpers.py b/InvenTree/InvenTree/helpers.py index 36cd288232..9e6e24acb8 100644 --- a/InvenTree/InvenTree/helpers.py +++ b/InvenTree/InvenTree/helpers.py @@ -224,7 +224,7 @@ def increment(n): groups = result.groups() # If we cannot match the regex, then simply return the provided value - if not len(groups) == 2: + if len(groups) != 2: return value prefix, number = groups @@ -536,7 +536,7 @@ def extract_serial_numbers(serials, expected_quantity, next_number: int): raise ValidationError([_("No serial numbers found")]) # The number of extracted serial numbers must match the expected quantity - if not expected_quantity == len(numbers): + if expected_quantity != len(numbers): raise ValidationError([_("Number of unique serial numbers ({s}) must match quantity ({q})").format(s=len(numbers), q=expected_quantity)]) return numbers @@ -575,7 +575,7 @@ def validateFilterString(value, model=None): pair = group.split('=') - if not len(pair) == 2: + if len(pair) != 2: raise ValidationError( "Invalid group: {g}".format(g=group) ) diff --git a/InvenTree/InvenTree/metadata.py b/InvenTree/InvenTree/metadata.py index c3ae8f6127..ae520e9dcb 100644 --- a/InvenTree/InvenTree/metadata.py +++ b/InvenTree/InvenTree/metadata.py @@ -250,7 +250,7 @@ class InvenTreeMetadata(SimpleMetadata): field_info = super().get_field_info(field) # If a default value is specified for the serializer field, add it! - if 'default' not in field_info and not field.default == empty: + if 'default' not in field_info and field.default != empty: field_info['default'] = field.get_default() # Force non-nullable fields to read as "required" diff --git a/InvenTree/InvenTree/models.py b/InvenTree/InvenTree/models.py index 99232519dc..92db2012f8 100644 --- a/InvenTree/InvenTree/models.py +++ b/InvenTree/InvenTree/models.py @@ -259,7 +259,7 @@ class InvenTreeAttachment(models.Model): new_file = os.path.abspath(new_file) # Check that there are no directory tricks going on... - if not os.path.dirname(new_file) == attachment_dir: + if os.path.dirname(new_file) != attachment_dir: logger.error(f"Attempted to rename attachment outside valid directory: '{new_file}'") raise ValidationError(_("Invalid attachment directory")) diff --git a/InvenTree/InvenTree/settings.py b/InvenTree/InvenTree/settings.py index 2817664908..cba4ab4c6a 100644 --- a/InvenTree/InvenTree/settings.py +++ b/InvenTree/InvenTree/settings.py @@ -658,7 +658,7 @@ AUTH_PASSWORD_VALIDATORS = [ EXTRA_URL_SCHEMES = CONFIG.get('extra_url_schemes', []) -if not type(EXTRA_URL_SCHEMES) in [list]: # pragma: no cover +if type(EXTRA_URL_SCHEMES) not in [list]: # pragma: no cover logger.warning("extra_url_schemes not correctly formatted") EXTRA_URL_SCHEMES = [] diff --git a/InvenTree/InvenTree/tasks.py b/InvenTree/InvenTree/tasks.py index c156d421ab..49a4049be5 100644 --- a/InvenTree/InvenTree/tasks.py +++ b/InvenTree/InvenTree/tasks.py @@ -204,7 +204,7 @@ def check_for_updates(): response = requests.get('https://api.github.com/repos/inventree/inventree/releases/latest') - if not response.status_code == 200: + if response.status_code != 200: raise ValueError(f'Unexpected status code from GitHub API: {response.status_code}') data = json.loads(response.text) @@ -216,13 +216,13 @@ def check_for_updates(): match = re.match(r"^.*(\d+)\.(\d+)\.(\d+).*$", tag) - if not len(match.groups()) == 3: + if len(match.groups()) != 3: logger.warning(f"Version '{tag}' did not match expected pattern") return latest_version = [int(x) for x in match.groups()] - if not len(latest_version) == 3: + if len(latest_version) != 3: raise ValueError(f"Version '{tag}' is not correct format") logger.info(f"Latest InvenTree version: '{tag}'") diff --git a/InvenTree/InvenTree/views.py b/InvenTree/InvenTree/views.py index 6291b321a8..d70752ad00 100644 --- a/InvenTree/InvenTree/views.py +++ b/InvenTree/InvenTree/views.py @@ -627,7 +627,7 @@ class SetPasswordView(AjaxUpdateView): if valid: # Passwords must match - if not p1 == p2: + if p1 != p2: error = _('Password fields must match') form.add_error('enter_password', error) form.add_error('confirm_password', error)