Linting fixes

master
Ferry Boender 4 years ago
parent 786bd36264
commit b1d89fa12a
  1. 9
      src/formdefinition.py
  2. 2
      src/scriptform.py

@ -152,7 +152,7 @@ class FormDefinition(object):
try: try:
value = int(value) value = int(value)
except ValueError: 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): if minval is not None and value < int(minval):
raise ValidationError("Minimum value is {0}".format(minval)) raise ValidationError("Minimum value is {0}".format(minval))
if maxval is not None and value > int(maxval): if maxval is not None and value > int(maxval):
@ -173,7 +173,7 @@ class FormDefinition(object):
try: try:
value = float(value) value = float(value)
except ValueError: 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): if minval is not None and value < float(minval):
raise ValidationError("Minimum value is {0}".format(minval)) raise ValidationError("Minimum value is {0}".format(minval))
if maxval is not None and value > float(maxval): if maxval is not None and value > float(maxval):
@ -194,7 +194,8 @@ class FormDefinition(object):
try: try:
value = datetime.datetime.strptime(value, '%Y-%m-%d').date() value = datetime.datetime.strptime(value, '%Y-%m-%d').date()
except ValueError: 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 minval is not None:
if value < datetime.datetime.strptime(minval, '%Y-%m-%d').date(): if value < datetime.datetime.strptime(minval, '%Y-%m-%d').date():
@ -290,7 +291,7 @@ class FormDefinition(object):
except KeyError: except KeyError:
# Field is missing. Check if it's required. # Field is missing. Check if it's required.
if 'required' in field_def and field_def['required'] is True: if 'required' in field_def and field_def['required'] is True:
raise ValidationError("Invalid file upload") raise ValidationError("Invalid file upload") from None
else: else:
return '' return ''

@ -12,6 +12,7 @@ import json
import logging import logging
import threading import threading
import hashlib import hashlib
import getpass
if hasattr(sys, 'dont_write_bytecode'): if hasattr(sys, 'dont_write_bytecode'):
sys.dont_write_bytecode = True sys.dont_write_bytecode = True
@ -201,7 +202,6 @@ def main(): # pragma: no cover
if options.generate_pw: if options.generate_pw:
# Generate a password for use in the `users` section # Generate a password for use in the `users` section
import getpass
plain_pw = getpass.getpass() plain_pw = getpass.getpass()
if plain_pw != getpass.getpass('Repeat password: '): if plain_pw != getpass.getpass('Repeat password: '):
sys.stderr.write("Passwords do not match.\n") sys.stderr.write("Passwords do not match.\n")

Loading…
Cancel
Save