2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-07-05 13:10:57 +00:00

Add more checks to pre-commit (#3132)

* Add bandit to pre-commit checks

* fix catchall exceptions

* remove unused definitons

* remove unuseed ariables

* Add docstring

* fix B006, B008 errors

* fix B007 error

* ignore B009

* Add checks for formatting and naming
This commit is contained in:
Matthias Mair
2022-06-06 00:56:52 +02:00
committed by GitHub
parent bbbfd003e0
commit f38386b13c
56 changed files with 154 additions and 109 deletions

View File

@ -593,7 +593,7 @@ class Part(MetadataMixin, MPTTModel):
try:
latest = int(latest)
return latest
except:
except Exception:
# not an integer so 0
return 0
@ -610,7 +610,7 @@ class Part(MetadataMixin, MPTTModel):
# Attempt to turn into an integer
try:
latest = int(latest)
except:
except Exception:
pass
if type(latest) is int:
@ -2283,7 +2283,7 @@ class PartTestTemplate(models.Model):
def validate_template_name(name):
"""Prevent illegal characters in "name" field for PartParameterTemplate."""
for c in "!@#$%^&*()<>{}[].,?/\\|~`_+-=\'\"":
for c in "!@#$%^&*()<>{}[].,?/\\|~`_+-=\'\"": # noqa: P103
if c in str(name):
raise ValidationError(_(f"Illegal character in template name ({c})"))