From 9f8f0eab912b1c9875374baf6aff7564407e82f3 Mon Sep 17 00:00:00 2001 From: Nicolas F Date: Sun, 24 Feb 2019 21:54:17 +0100 Subject: [PATCH] fix newer linter warnings Apparently bare excepts are literally Hitler, and we have some new import sorting rules. Hooray! --- nyaa/bencode.py | 4 ++-- nyaa/forms.py | 3 ++- nyaa/views/__init__.py | 2 +- nyaa/views/account.py | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/nyaa/bencode.py b/nyaa/bencode.py index 6cdd14c..1866dd1 100644 --- a/nyaa/bencode.py +++ b/nyaa/bencode.py @@ -67,7 +67,7 @@ def _bencode_decode(file_object, decode_keys_as_utf8=True): elif c == _B_END: try: return int(int_bytes.decode('utf8')) - except Exception as e: + except Exception: raise create_ex('Unable to parse int') # not a digit OR '-' in the middle of the int @@ -109,7 +109,7 @@ def _bencode_decode(file_object, decode_keys_as_utf8=True): raise create_ex('Unexpected input while reading string length: ' + repr(c)) try: str_len = int(str_len_bytes.decode()) - except Exception as e: + except Exception: raise create_ex('Unable to parse bytestring length') bytestring = file_object.read(str_len) diff --git a/nyaa/forms.py b/nyaa/forms.py index 7d349c1..6cabfa2 100644 --- a/nyaa/forms.py +++ b/nyaa/forms.py @@ -11,8 +11,9 @@ from wtforms import (BooleanField, HiddenField, PasswordField, SelectField, Stri SubmitField, TextAreaField) from wtforms.validators import (DataRequired, Email, EqualTo, Length, Optional, Regexp, StopValidation, ValidationError) +from wtforms.widgets import HTMLString # For DisabledSelectField from wtforms.widgets import Select as SelectWidget # For DisabledSelectField -from wtforms.widgets import HTMLString, html_params # For DisabledSelectField +from wtforms.widgets import html_params import dns.exception import dns.resolver diff --git a/nyaa/views/__init__.py b/nyaa/views/__init__.py index 32f745b..ef3f3c4 100644 --- a/nyaa/views/__init__.py +++ b/nyaa/views/__init__.py @@ -29,7 +29,7 @@ def _maintenance_mode_hook(): flask.flash(flask.Markup(message), 'danger') try: target_url = flask.url_for(endpoint) - except: + except Exception: # Non-GET-able endpoint, try referrer or default to home page target_url = flask.request.referrer or flask.url_for('main.home') return flask.redirect(target_url) diff --git a/nyaa/views/account.py b/nyaa/views/account.py index 6534779..8f30001 100644 --- a/nyaa/views/account.py +++ b/nyaa/views/account.py @@ -154,7 +154,7 @@ def password_reset(payload=None): s = get_serializer() try: request_timestamp, pw_hash, user_id = s.loads(payload) - except: + except Exception: return flask.abort(404) user = models.User.by_id(user_id)