Support for Click 8.0.0 (#1465)

* `'.'` to `['.']` as path default(s)

view https://github.com/rq/rq/issues/1464#issuecomment-839649116, #1464

* DefaultSerializer class object to `rq.serializers.DefaultSerializer` in shared options

in defaults.py

#1464

* remove unused import

* make rq python 3.5 compatible
main
rpkak 4 years ago committed by GitHub
parent b84b39f75f
commit 428d75b9b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -21,11 +21,11 @@ from rq.defaults import (DEFAULT_CONNECTION_CLASS, DEFAULT_JOB_CLASS,
DEFAULT_QUEUE_CLASS, DEFAULT_WORKER_CLASS, DEFAULT_QUEUE_CLASS, DEFAULT_WORKER_CLASS,
DEFAULT_RESULT_TTL, DEFAULT_WORKER_TTL, DEFAULT_RESULT_TTL, DEFAULT_WORKER_TTL,
DEFAULT_JOB_MONITORING_INTERVAL, DEFAULT_JOB_MONITORING_INTERVAL,
DEFAULT_LOGGING_FORMAT, DEFAULT_LOGGING_DATE_FORMAT) DEFAULT_LOGGING_FORMAT, DEFAULT_LOGGING_DATE_FORMAT,
DEFAULT_SERIALIZER_CLASS)
from rq.exceptions import InvalidJobOperationError from rq.exceptions import InvalidJobOperationError
from rq.registry import FailedJobRegistry, clean_registries from rq.registry import FailedJobRegistry, clean_registries
from rq.utils import import_attribute from rq.utils import import_attribute
from rq.serializers import DefaultSerializer
from rq.suspension import (suspend as connection_suspend, from rq.suspension import (suspend as connection_suspend,
resume as connection_resume, is_suspended) resume as connection_resume, is_suspended)
from rq.worker_registration import clean_worker_registry from rq.worker_registration import clean_worker_registry
@ -62,11 +62,11 @@ shared_options = [
default=DEFAULT_CONNECTION_CLASS, default=DEFAULT_CONNECTION_CLASS,
help='Redis client class to use'), help='Redis client class to use'),
click.option('--path', '-P', click.option('--path', '-P',
default='.', default=['.'],
help='Specify the import path.', help='Specify the import path.',
multiple=True), multiple=True),
click.option('--serializer', '-S', click.option('--serializer', '-S',
default=DefaultSerializer, default=DEFAULT_SERIALIZER_CLASS,
help='Path to serializer, defaults to rq.serializers.DefaultSerializer') help='Path to serializer, defaults to rq.serializers.DefaultSerializer')
] ]

@ -1,6 +1,7 @@
DEFAULT_JOB_CLASS = 'rq.job.Job' DEFAULT_JOB_CLASS = 'rq.job.Job'
DEFAULT_QUEUE_CLASS = 'rq.Queue' DEFAULT_QUEUE_CLASS = 'rq.Queue'
DEFAULT_WORKER_CLASS = 'rq.Worker' DEFAULT_WORKER_CLASS = 'rq.Worker'
DEFAULT_SERIALIZER_CLASS = 'rq.serializers.DefaultSerializer'
DEFAULT_CONNECTION_CLASS = 'redis.Redis' DEFAULT_CONNECTION_CLASS = 'redis.Redis'
DEFAULT_WORKER_TTL = 420 DEFAULT_WORKER_TTL = 420
DEFAULT_JOB_MONITORING_INTERVAL = 30 DEFAULT_JOB_MONITORING_INTERVAL = 30

@ -137,11 +137,11 @@ def import_attribute(name):
module_name = '.'.join(module_name_bits) module_name = '.'.join(module_name_bits)
module = importlib.import_module(module_name) module = importlib.import_module(module_name)
break break
except ModuleNotFoundError: except ImportError:
attribute_bits.insert(0, module_name_bits.pop()) attribute_bits.insert(0, module_name_bits.pop())
if module is None: if module is None:
raise ValueError(f'Invalid attribute name: {name}') raise ValueError('Invalid attribute name: %s' % name)
attribute_name = '.'.join(attribute_bits) attribute_name = '.'.join(attribute_bits)
if hasattr(module, attribute_name): if hasattr(module, attribute_name):
@ -153,7 +153,7 @@ def import_attribute(name):
attribute_owner = getattr(module, attribute_owner_name) attribute_owner = getattr(module, attribute_owner_name)
if not hasattr(attribute_owner, attribute_name): if not hasattr(attribute_owner, attribute_name):
raise ValueError(f'Invalid attribute name: {name}') raise ValueError('Invalid attribute name: %s' % name)
return getattr(attribute_owner, attribute_name) return getattr(attribute_owner, attribute_name)

Loading…
Cancel
Save