diff --git a/app/authentication/auth.py b/app/authentication/auth.py index f878ccda7..8abe2a067 100644 --- a/app/authentication/auth.py +++ b/app/authentication/auth.py @@ -113,7 +113,7 @@ def __get_token_issuer(auth_token): client = get_token_issuer(auth_token) except TokenIssuerError: raise AuthError("Invalid token: iss field not provided", 403) - except TokenDecodeError as e: + except TokenDecodeError: raise AuthError("Invalid token: signature, api token is not valid", 403) return client @@ -123,5 +123,5 @@ def handle_admin_key(auth_token, secret): decode_jwt_token(auth_token, secret) except TokenExpiredError: raise AuthError("Invalid token: expired, check that your system clock is accurate", 403) - except TokenDecodeError as e: + except TokenDecodeError: raise AuthError("Invalid token: signature, api token is not valid", 403) diff --git a/app/celery/process_ses_receipts_tasks.py b/app/celery/process_ses_receipts_tasks.py index d0279eb77..ad88fcc3c 100644 --- a/app/celery/process_ses_receipts_tasks.py +++ b/app/celery/process_ses_receipts_tasks.py @@ -14,6 +14,6 @@ def process_ses_results(self, response): errors = process_ses_response(response) if errors: current_app.logger.error(errors) - except Exception as exc: + except Exception: current_app.logger.exception('Error processing SES results') self.retry(queue=QueueNames.RETRY) diff --git a/app/celery/provider_tasks.py b/app/celery/provider_tasks.py index 113e79559..aec055246 100644 --- a/app/celery/provider_tasks.py +++ b/app/celery/provider_tasks.py @@ -21,7 +21,7 @@ def deliver_sms(self, notification_id): if not notification: raise NoResultFound() send_to_providers.send_sms_to_provider(notification) - except Exception as e: + except Exception: try: current_app.logger.exception( "SMS notification delivery for id: {} failed".format(notification_id) @@ -46,7 +46,7 @@ def deliver_email(self, notification_id): except InvalidEmailError as e: current_app.logger.exception(e) update_notification_status_by_id(notification_id, 'technical-failure') - except Exception as e: + except Exception: try: current_app.logger.exception( "RETRY: Email notification {} failed".format(notification_id) diff --git a/app/clients/email/__init__.py b/app/clients/email/__init__.py index 15f250496..b5ea93941 100644 --- a/app/clients/email/__init__.py +++ b/app/clients/email/__init__.py @@ -14,7 +14,7 @@ class EmailClient(Client): ''' def send_email(self, *args, **kwargs): - raise NotImplemented('TODO Need to implement.') + raise NotImplementedError('TODO Need to implement.') def get_name(self): - raise NotImplemented('TODO Need to implement.') + raise NotImplementedError('TODO Need to implement.') diff --git a/app/clients/sms/__init__.py b/app/clients/sms/__init__.py index e6accdb8a..9a3cb2baf 100644 --- a/app/clients/sms/__init__.py +++ b/app/clients/sms/__init__.py @@ -19,7 +19,7 @@ class SmsClient(Client): ''' def send_sms(self, *args, **kwargs): - raise NotImplemented('TODO Need to implement.') + raise NotImplementedError('TODO Need to implement.') def get_name(self): - raise NotImplemented('TODO Need to implement.') + raise NotImplementedError('TODO Need to implement.') diff --git a/app/commands.py b/app/commands.py index e6e495899..a4244fb33 100644 --- a/app/commands.py +++ b/app/commands.py @@ -316,7 +316,7 @@ def replay_service_callbacks(file_name, service_id): try: notification = Notification.query.filter_by(client_reference=ref.strip()).one() notifications.append(notification) - except NoResultFound as e: + except NoResultFound: errors.append("Reference: {} was not found in notifications.".format(ref)) for e in errors: diff --git a/app/utils.py b/app/utils.py index 3ceeed2e6..204de6ed5 100644 --- a/app/utils.py +++ b/app/utils.py @@ -121,6 +121,6 @@ def escape_special_characters(string): for special_character in ('\\', '_', '%', '/'): string = string.replace( special_character, - '\{}'.format(special_character) + r'\{}'.format(special_character) ) return string diff --git a/requirements-app.txt b/requirements-app.txt index fccb5d8c0..e75740910 100644 --- a/requirements-app.txt +++ b/requirements-app.txt @@ -23,9 +23,7 @@ SQLAlchemy==1.2.12 notifications-python-client==5.2.0 # PaaS -awscli==1.15.82 # pyup: ignore awscli-cwlogs>=1.4,<1.5 -botocore<1.11.0 # pyup: ignore # Putting upgrade on hold due to v1.0.0 using sha512 instead of sha1 by default diff --git a/requirements.txt b/requirements.txt index 6a96b0045..37613bb91 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,9 +25,7 @@ SQLAlchemy==1.2.12 notifications-python-client==5.2.0 # PaaS -awscli==1.15.82 # pyup: ignore awscli-cwlogs>=1.4,<1.5 -botocore<1.11.0 # pyup: ignore # Putting upgrade on hold due to v1.0.0 using sha512 instead of sha1 by default @@ -38,20 +36,22 @@ git+https://github.com/alphagov/notifications-utils.git@30.5.6#egg=notifications git+https://github.com/alphagov/boto.git@2.43.0-patch3#egg=boto==2.43.0-patch3 ## The following requirements were added by pip freeze: -alembic==1.0.1 +alembic==1.0.2 amqp==1.4.9 anyjson==0.3.3 +awscli==1.16.49 bcrypt==3.1.4 billiard==3.3.0.23 bleach==2.1.3 boto3==1.6.16 +botocore==1.12.39 certifi==2018.10.15 chardet==3.0.4 Click==7.0 colorama==0.3.9 docutils==0.14 Flask-Redis==0.3.0 -future==0.16.0 +future==0.17.1 greenlet==0.4.15 html5lib==1.0.1 idna==2.7 @@ -59,7 +59,7 @@ Jinja2==2.10 jmespath==0.9.3 kombu==3.0.37 Mako==1.0.7 -MarkupSafe==1.0 +MarkupSafe==1.1.0 mistune==0.8.3 monotonic==1.5 orderedset==2.0.1 @@ -67,11 +67,11 @@ phonenumbers==8.9.4 pyasn1==0.4.4 pycparser==2.19 PyPDF2==1.26.0 -python-dateutil==2.7.3 +python-dateutil==2.7.5 python-editor==1.0.3 python-json-logger==0.1.8 -pytz==2018.6 -PyYAML==3.13 +pytz==2018.7 +PyYAML==3.12 redis==2.10.6 requests==2.20.0 rsa==3.4.2 @@ -79,6 +79,6 @@ s3transfer==0.1.13 six==1.11.0 smartypants==2.0.1 statsd==3.2.2 -urllib3==1.24 +urllib3==1.24.1 webencodings==0.5.1 Werkzeug==0.14.1 diff --git a/requirements_for_test.txt b/requirements_for_test.txt index e25a44f33..d286b3400 100644 --- a/requirements_for_test.txt +++ b/requirements_for_test.txt @@ -1,11 +1,11 @@ -r requirements.txt -flake8==3.5.0 -pytest==3.9.3 -moto==1.3.6 +flake8==3.6.0 +pytest==3.10.0 +moto==1.3.7 pytest-env==0.6.2 pytest-mock==1.10.0 pytest-cov==2.6.0 -pytest-xdist==1.23.2 +pytest-xdist==1.24.0 coveralls==1.5.1 freezegun==0.3.11 requests-mock==1.5.2 diff --git a/setup.cfg b/setup.cfg index 4db8682ef..cd4e3f3e4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,7 @@ [tool:pytest] xfail_strict=true + + +[flake8] +# W504 line break after binary operator +extend_ignore=W504