Removes .utils.is_iterable
This commit is contained in:
Родитель
9261fe132c
Коммит
8ee50a3d9f
|
@ -13,14 +13,13 @@ import numbers
|
|||
import re
|
||||
|
||||
from bisect import bisect, bisect_left
|
||||
from collections import namedtuple
|
||||
from collections import Iterable, namedtuple
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from kombu.utils import cached_property
|
||||
|
||||
from . import current_app
|
||||
from .five import python_2_unicode_compatible, range, string_t
|
||||
from .utils import is_iterable
|
||||
from .utils.collections import AttributeDict
|
||||
from .utils.timeutils import (
|
||||
weekday, maybe_timedelta, remaining, humanize_seconds,
|
||||
|
@ -428,7 +427,7 @@ class crontab(schedule):
|
|||
result = crontab_parser(max_, min_).parse(cronspec)
|
||||
elif isinstance(cronspec, set):
|
||||
result = cronspec
|
||||
elif is_iterable(cronspec):
|
||||
elif isinstance(cronspec, Iterable):
|
||||
result = set(cronspec)
|
||||
else:
|
||||
raise TypeError(CRON_INVALID_TYPE.format(type=type(cronspec)))
|
||||
|
|
|
@ -8,7 +8,6 @@ from kombu import Queue
|
|||
|
||||
from celery.utils import (
|
||||
chunks,
|
||||
is_iterable,
|
||||
cached_property,
|
||||
jsonify,
|
||||
)
|
||||
|
@ -72,12 +71,6 @@ class test_chunks(Case):
|
|||
|
||||
class test_utils(Case):
|
||||
|
||||
def test_is_iterable(self):
|
||||
for a in 'f', ['f'], ('f',), {'f': 'f'}:
|
||||
self.assertTrue(is_iterable(a))
|
||||
for b in object(), 1:
|
||||
self.assertFalse(is_iterable(b))
|
||||
|
||||
def test_cached_property(self):
|
||||
|
||||
def fun(obj):
|
||||
|
|
|
@ -21,21 +21,13 @@ from .functional import memoize # noqa
|
|||
from .nodenames import worker_direct, nodename, nodesplit
|
||||
|
||||
__all__ = ['worker_direct',
|
||||
'is_iterable', 'maybe_reraise', 'strtobool',
|
||||
'maybe_reraise', 'strtobool',
|
||||
'jsonify', 'gen_task_name', 'nodename', 'nodesplit',
|
||||
'cached_property']
|
||||
|
||||
PY3 = sys.version_info[0] == 3
|
||||
|
||||
|
||||
def is_iterable(obj):
|
||||
try:
|
||||
iter(obj)
|
||||
except TypeError:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
def maybe_reraise():
|
||||
"""Re-raise if an exception is currently being handled, or return
|
||||
otherwise."""
|
||||
|
|
Загрузка…
Ссылка в новой задаче