Drop python2-specific syntax (#1674)

* Drop syntax required only for Python 2

* Drop python2-style super() calls

Co-authored-by: Selwin Ong <selwin.ong@gmail.com>
main
Hugo 2 years ago committed by GitHub
parent 61a4a1720b
commit d5175c38da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,8 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
def slow_fib(n):
if n <= 1:
return 1

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import os
import time

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from rq import Connection, Queue, Worker
if __name__ == '__main__':

@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
# flake8: noqa
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from .connections import (Connection, get_current_connection, pop_connection,
push_connection, use_connection)

@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-
"""
RQ command line tool
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from functools import update_wrapper
import os

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import sys
import importlib
import time

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import sys

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from functools import partial
from redis import Redis

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from contextlib import contextmanager
from redis import Redis

@ -1,8 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import logging
from rq import get_current_connection
from rq import Worker

@ -1,8 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
def register_sentry(sentry_dsn, **opts):
"""Given a Raven client and an RQ worker, registers exception handlers
with the worker so exceptions are logged to Sentry.

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from functools import wraps
from rq.compat import string_types

@ -1,9 +1,6 @@
# -*- coding: utf-8 -*-
"""
Some dummy tasks that are well-suited for generating load for testing purposes.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import random
import time

@ -1,8 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
class NoSuchJobError(Exception):
pass
@ -30,7 +25,7 @@ class DequeueTimeout(Exception):
class ShutDownImminentException(Exception):
def __init__(self, msg, extra_info):
self.extra_info = extra_info
super(ShutDownImminentException, self).__init__(msg)
super().__init__(msg)
class TimeoutFormatError(Exception):

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import inspect
import json
import pickle

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# flake8: noqa
"""
werkzeug.local

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import logging
import sys

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import uuid
import sys
import warnings

@ -264,7 +264,7 @@ class ScheduledJobRegistry(BaseRegistry):
key_template = 'rq:scheduled:{0}'
def __init__(self, *args, **kwargs):
super(ScheduledJobRegistry, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
# The underlying implementation of get_jobs_to_enqueue() is
# the same as get_expired_job_ids, but get_expired_job_ids() doesn't
# make sense in this context

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import ctypes
import signal
import threading

@ -1,12 +1,9 @@
# -*- coding: utf-8 -*-
"""
Miscellaneous helper functions.
The formatter for ANSI colored console output is heavily based on Pygments
terminal colorizing code, originally by Georg Brandl.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import calendar
import datetime
@ -102,7 +99,7 @@ class ColorizingStreamHandler(logging.StreamHandler):
def __init__(self, exclude=None, *args, **kwargs):
self.exclude = exclude
super(ColorizingStreamHandler, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
@property
def is_tty(self):

@ -1,5 +1 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
VERSION = '1.10.1'

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import errno
import logging
import os

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import logging
import os

@ -1,5 +1 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
REDIS_HOST = "testhost.example.com"

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
REDIS_HOST = "testhost.example.com"
REDIS_PORT = 6378
REDIS_DB = 2

@ -1,6 +1,2 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
REDIS_HOST = "testhost.example.com"
SENTRY_DSN = 'https://123@sentry.io/123'

@ -1,10 +1,7 @@
# -*- coding: utf-8 -*-
"""
This file contains all jobs that are used in tests. Each of these test
fixtures has a slighty different characteristics.
"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import os
import time
@ -150,7 +147,7 @@ class UnicodeStringObject:
return u'é'
class ClassWithAStaticMethod(object):
class ClassWithAStaticMethod:
@staticmethod
def static_method():
return u"I'm a static method"

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from datetime import datetime, timezone, timedelta
from time import sleep
from uuid import uuid4
@ -45,7 +41,7 @@ class TestRQCli(RQTestCase):
"""Test rq_cli script"""
def setUp(self):
super(TestRQCli, self).setUp()
super().setUp()
db_num = self.testconn.connection_pool.connection_kwargs['db']
self.redis_url = 'redis://127.0.0.1:6379/%d' % db_num
self.connection = Redis.from_url(self.redis_url)

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from redis import Redis
from rq import Connection, Queue, use_connection, get_current_connection, pop_connection

@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from unittest import mock
from redis import Redis
from rq.decorators import job
@ -16,7 +13,7 @@ from tests.fixtures import decorated_job
class TestDecorator(RQTestCase):
def setUp(self):
super(TestDecorator, self).setUp()
super().setUp()
def test_decorator_preserves_functionality(self):
"""Ensure that a decorated function's functionality is still preserved.

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from rq import Queue
from tests import RQTestCase, fixtures

@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
import json
from rq.serializers import JSONSerializer
import time

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import json
from datetime import datetime, timedelta, timezone
from rq.serializers import DefaultSerializer, JSONSerializer

@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from datetime import datetime, timedelta
from rq.serializers import JSONSerializer
@ -26,7 +23,7 @@ class CustomJob(Job):
class TestRegistry(RQTestCase):
def setUp(self):
super(TestRegistry, self).setUp()
super().setUp()
self.registry = StartedJobRegistry(connection=self.testconn)
def test_init(self):
@ -273,7 +270,7 @@ class TestRegistry(RQTestCase):
class TestFinishedJobRegistry(RQTestCase):
def setUp(self):
super(TestFinishedJobRegistry, self).setUp()
super().setUp()
self.registry = FinishedJobRegistry(connection=self.testconn)
def test_key(self):
@ -321,7 +318,7 @@ class TestFinishedJobRegistry(RQTestCase):
class TestDeferredRegistry(RQTestCase):
def setUp(self):
super(TestDeferredRegistry, self).setUp()
super().setUp()
self.registry = DeferredJobRegistry(connection=self.testconn)
def test_key(self):

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from rq import Queue
from rq.cli import main
from rq.cli.helpers import read_config_file
@ -25,7 +21,7 @@ class FakeSentry:
class TestSentry(RQTestCase):
def setUp(self):
super(TestSentry, self).setUp()
super().setUp()
db_num = self.testconn.connection_pool.connection_kwargs['db']
self.redis_url = 'redis://127.0.0.1:6379/%d' % db_num

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import json
import pickle
import pickletools

@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import re
import datetime
from unittest import mock

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import json
import os
import psutil
@ -1254,7 +1250,7 @@ def schedule_access_self():
@pytest.mark.skipif(sys.platform == 'darwin', reason='Fails on OS X')
class TestWorkerSubprocess(RQTestCase):
def setUp(self):
super(TestWorkerSubprocess, self).setUp()
super().setUp()
db_num = self.testconn.connection_pool.connection_kwargs['db']
self.redis_url = 'redis://127.0.0.1:6379/%d' % db_num
@ -1286,7 +1282,7 @@ class TestWorkerSubprocess(RQTestCase):
@skipIf('pypy' in sys.version.lower(), 'these tests often fail on pypy')
class HerokuWorkerShutdownTestCase(TimeoutTestCase, RQTestCase):
def setUp(self):
super(HerokuWorkerShutdownTestCase, self).setUp()
super().setUp()
self.sandbox = '/tmp/rq_shutdown/'
os.makedirs(self.sandbox)
@ -1372,7 +1368,7 @@ class HerokuWorkerShutdownTestCase(TimeoutTestCase, RQTestCase):
class TestExceptionHandlerMessageEncoding(RQTestCase):
def setUp(self):
super(TestExceptionHandlerMessageEncoding, self).setUp()
super().setUp()
self.worker = Worker("foo")
self.worker._exc_handlers = []
# Mimic how exception info is actually passed forwards

Loading…
Cancel
Save