diff --git a/.flake8 b/.flake8 index 39d0f275e4..75139b4b73 100644 --- a/.flake8 +++ b/.flake8 @@ -2,6 +2,7 @@ max-line-length = 120 application-import-names = dmoj,judge,django_ace,event_socket_server import-order-style = pycharm +enable-extensions = G ignore = W504, # line break occurred after a binary operator # allow only generator_stop and annotations future imports diff --git a/.travis.yml b/.travis.yml index 8d54691a7a..89da0de6ea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: python python: 3.7 -install: pip install flake8 flake8-import-order flake8-future-import flake8-commas +install: pip install flake8 flake8-import-order flake8-future-import flake8-commas flake8-logging-format script: - flake8 --version - flake8 diff --git a/dmoj/celery.py b/dmoj/celery.py index 764569d68f..ccdf66abce 100644 --- a/dmoj/celery.py +++ b/dmoj/celery.py @@ -27,6 +27,5 @@ @task_failure.connect() def celery_failure_log(sender, task_id, exception, traceback, *args, **kwargs): - logger.exception('Celery Task {task_name}: {task_id} on {hostname}'.format( - task_name=sender.name, task_id=task_id, hostname=socket.gethostname(), - ), exc_info=(type(exception), exception, traceback)) + logger.error('Celery Task %s: %s on %s', sender.name, task_id, socket.gethostname(), # noqa: G201 + exc_info=(type(exception), exception, traceback)) diff --git a/judge/utils/pwned.py b/judge/utils/pwned.py index 450a135c14..fa3df63da1 100644 --- a/judge/utils/pwned.py +++ b/judge/utils/pwned.py @@ -66,9 +66,9 @@ def _get_pwned(prefix): ), ) response.raise_for_status() - except requests.RequestException as e: + except requests.RequestException: # Gracefully handle timeouts and HTTP error response codes. - log.warning('Skipped Pwned Passwords check due to error: %r', e) + log.warning('Skipped Pwned Passwords check due to error', exc_info=True) return None results = {} diff --git a/judge/utils/texoid.py b/judge/utils/texoid.py index a095bd5ee1..8e05e27790 100644 --- a/judge/utils/texoid.py +++ b/judge/utils/texoid.py @@ -35,10 +35,10 @@ def query_texoid(self, document, hash): if e.response.status == 400: logger.error('Texoid failed to render: %s\n%s', document, e.response.text) else: - logger.exception('Failed to connect to texoid for: %s' % document) + logger.exception('Failed to connect to texoid for: %s', document) return except Exception: - logger.exception('Failed to connect to texoid for: %s' % document) + logger.exception('Failed to connect to texoid for: %s', document) return try: