From b1d89fa12ae9d40a645e4ddcbbbfc9346adb9059 Mon Sep 17 00:00:00 2001 From: Ferry Boender Date: Sat, 20 Mar 2021 07:34:27 +0000 Subject: [PATCH] Linting fixes --- src/formdefinition.py | 9 +++++---- src/scriptform.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/formdefinition.py b/src/formdefinition.py index 4e0e7aa..8efb2e3 100644 --- a/src/formdefinition.py +++ b/src/formdefinition.py @@ -152,7 +152,7 @@ class FormDefinition(object): try: value = int(value) except ValueError: - raise ValidationError("Must be an integer number") + raise ValidationError("Must be an integer number") from None if minval is not None and value < int(minval): raise ValidationError("Minimum value is {0}".format(minval)) if maxval is not None and value > int(maxval): @@ -173,7 +173,7 @@ class FormDefinition(object): try: value = float(value) except ValueError: - raise ValidationError("Must be an real (float) number") + raise ValidationError("Must be an real (float) number") from None if minval is not None and value < float(minval): raise ValidationError("Minimum value is {0}".format(minval)) if maxval is not None and value > float(maxval): @@ -194,7 +194,8 @@ class FormDefinition(object): try: value = datetime.datetime.strptime(value, '%Y-%m-%d').date() except ValueError: - raise ValidationError("Invalid date, must be in form YYYY-MM-DD") + e_msg = "Invalid date, must be in form YYYY-MM-DD" + raise ValidationError(e_msg) from None if minval is not None: if value < datetime.datetime.strptime(minval, '%Y-%m-%d').date(): @@ -290,7 +291,7 @@ class FormDefinition(object): except KeyError: # Field is missing. Check if it's required. if 'required' in field_def and field_def['required'] is True: - raise ValidationError("Invalid file upload") + raise ValidationError("Invalid file upload") from None else: return '' diff --git a/src/scriptform.py b/src/scriptform.py index 310fcd1..b146c5b 100755 --- a/src/scriptform.py +++ b/src/scriptform.py @@ -12,6 +12,7 @@ import json import logging import threading import hashlib +import getpass if hasattr(sys, 'dont_write_bytecode'): sys.dont_write_bytecode = True @@ -201,7 +202,6 @@ def main(): # pragma: no cover if options.generate_pw: # Generate a password for use in the `users` section - import getpass plain_pw = getpass.getpass() if plain_pw != getpass.getpass('Repeat password: '): sys.stderr.write("Passwords do not match.\n")