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): def slow_fib(n):
if n <= 1: if n <= 1:
return 1 return 1

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import os import os
import time 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 from rq import Connection, Queue, Worker
if __name__ == '__main__': if __name__ == '__main__':

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

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

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

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

@ -1,7 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from functools import partial from functools import partial
from redis import Redis 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 contextlib import contextmanager
from redis import Redis from redis import Redis

@ -1,8 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import logging import logging
from rq import get_current_connection from rq import get_current_connection
from rq import Worker 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): def register_sentry(sentry_dsn, **opts):
"""Given a Raven client and an RQ worker, registers exception handlers """Given a Raven client and an RQ worker, registers exception handlers
with the worker so exceptions are logged to Sentry. 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 functools import wraps
from rq.compat import string_types 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. 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 random
import time import time

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

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

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

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

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

@ -264,7 +264,7 @@ class ScheduledJobRegistry(BaseRegistry):
key_template = 'rq:scheduled:{0}' key_template = 'rq:scheduled:{0}'
def __init__(self, *args, **kwargs): 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 underlying implementation of get_jobs_to_enqueue() is
# the same as get_expired_job_ids, but get_expired_job_ids() doesn't # the same as get_expired_job_ids, but get_expired_job_ids() doesn't
# make sense in this context # 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 ctypes
import signal import signal
import threading import threading

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

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

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

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

@ -1,5 +1 @@
# -*- coding: utf-8 -*-
from __future__ import (absolute_import, division, print_function,
unicode_literals)
REDIS_HOST = "testhost.example.com" 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_HOST = "testhost.example.com"
REDIS_PORT = 6378 REDIS_PORT = 6378
REDIS_DB = 2 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" REDIS_HOST = "testhost.example.com"
SENTRY_DSN = 'https://123@sentry.io/123' 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 This file contains all jobs that are used in tests. Each of these test
fixtures has a slighty different characteristics. fixtures has a slighty different characteristics.
""" """
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import os import os
import time import time
@ -150,7 +147,7 @@ class UnicodeStringObject:
return u'é' return u'é'
class ClassWithAStaticMethod(object): class ClassWithAStaticMethod:
@staticmethod @staticmethod
def static_method(): def static_method():
return u"I'm a 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 datetime import datetime, timezone, timedelta
from time import sleep from time import sleep
from uuid import uuid4 from uuid import uuid4
@ -45,7 +41,7 @@ class TestRQCli(RQTestCase):
"""Test rq_cli script""" """Test rq_cli script"""
def setUp(self): def setUp(self):
super(TestRQCli, self).setUp() super().setUp()
db_num = self.testconn.connection_pool.connection_kwargs['db'] db_num = self.testconn.connection_pool.connection_kwargs['db']
self.redis_url = 'redis://127.0.0.1:6379/%d' % db_num self.redis_url = 'redis://127.0.0.1:6379/%d' % db_num
self.connection = Redis.from_url(self.redis_url) 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 redis import Redis
from rq import Connection, Queue, use_connection, get_current_connection, pop_connection 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 unittest import mock
from redis import Redis from redis import Redis
from rq.decorators import job from rq.decorators import job
@ -16,7 +13,7 @@ from tests.fixtures import decorated_job
class TestDecorator(RQTestCase): class TestDecorator(RQTestCase):
def setUp(self): def setUp(self):
super(TestDecorator, self).setUp() super().setUp()
def test_decorator_preserves_functionality(self): def test_decorator_preserves_functionality(self):
"""Ensure that a decorated function's functionality is still preserved. """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 rq import Queue
from tests import RQTestCase, fixtures from tests import RQTestCase, fixtures

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

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

@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from datetime import datetime, timedelta from datetime import datetime, timedelta
from rq.serializers import JSONSerializer from rq.serializers import JSONSerializer
@ -26,7 +23,7 @@ class CustomJob(Job):
class TestRegistry(RQTestCase): class TestRegistry(RQTestCase):
def setUp(self): def setUp(self):
super(TestRegistry, self).setUp() super().setUp()
self.registry = StartedJobRegistry(connection=self.testconn) self.registry = StartedJobRegistry(connection=self.testconn)
def test_init(self): def test_init(self):
@ -273,7 +270,7 @@ class TestRegistry(RQTestCase):
class TestFinishedJobRegistry(RQTestCase): class TestFinishedJobRegistry(RQTestCase):
def setUp(self): def setUp(self):
super(TestFinishedJobRegistry, self).setUp() super().setUp()
self.registry = FinishedJobRegistry(connection=self.testconn) self.registry = FinishedJobRegistry(connection=self.testconn)
def test_key(self): def test_key(self):
@ -321,7 +318,7 @@ class TestFinishedJobRegistry(RQTestCase):
class TestDeferredRegistry(RQTestCase): class TestDeferredRegistry(RQTestCase):
def setUp(self): def setUp(self):
super(TestDeferredRegistry, self).setUp() super().setUp()
self.registry = DeferredJobRegistry(connection=self.testconn) self.registry = DeferredJobRegistry(connection=self.testconn)
def test_key(self): 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 import Queue
from rq.cli import main from rq.cli import main
from rq.cli.helpers import read_config_file from rq.cli.helpers import read_config_file
@ -25,7 +21,7 @@ class FakeSentry:
class TestSentry(RQTestCase): class TestSentry(RQTestCase):
def setUp(self): def setUp(self):
super(TestSentry, self).setUp() super().setUp()
db_num = self.testconn.connection_pool.connection_kwargs['db'] db_num = self.testconn.connection_pool.connection_kwargs['db']
self.redis_url = 'redis://127.0.0.1:6379/%d' % db_num 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 json
import pickle import pickle
import pickletools import pickletools

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

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

Loading…
Cancel
Save