Skip to content

Commit e7b87ea

Browse files
committed
imports fix
1 parent 46f6fb2 commit e7b87ea

File tree

6 files changed

+22
-14
lines changed

6 files changed

+22
-14
lines changed

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from yatq.dto import TaskState
1414
from yatq.queue import Queue
1515

16-
if not AIOREDIS_USE or aioredis.__version__ >= "2.0": # pragma: no cover
16+
if not AIOREDIS_USE or aioredis.__version__ >= "2.0":
1717

1818
async def create_redis_connection(redis_uri: str):
1919
return aioredis.from_url(redis_uri)

yatq/function.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
from string import Template
55
from typing import Any, Dict
66

7-
try:
7+
from yatq.py_version import AIOREDIS_USE
8+
9+
if AIOREDIS_USE:
810
from aioredis import Redis
9-
except ImportError:
10-
from redis.asyncio import Redis # type: ignore
11+
else:
12+
from redis.asyncio import Redis # type: ignore # pragma: no cover
1113

1214
from yatq.redis_compat import NoScriptError, eval_sha # type: ignore
1315

yatq/queue.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
from typing import Any, Dict, Optional, Union
88
from uuid import uuid4
99

10-
try:
11-
from aioredis import Redis # pragma: no cover
12-
except ImportError:
10+
from yatq.py_version import AIOREDIS_USE
11+
12+
if AIOREDIS_USE:
13+
from aioredis import Redis
14+
else:
1315
from redis.asyncio import Redis # type: ignore # pragma: no cover
1416

1517
from .defaults import (

yatq/redis_compat.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Any, Tuple
33
from yatq.py_version import AIOREDIS_USE
44

5-
if AIOREDIS_USE: # pragma: no cover
5+
if AIOREDIS_USE:
66
import aioredis
77

88
if aioredis.__version__ >= "2.0":
@@ -13,7 +13,7 @@ async def eval_sha(
1313
): # pragma: no cover
1414
return await client.evalsha(digest, 0, *args)
1515

16-
else:
16+
else: # pragma: no cover
1717
from aioredis.errors import ReplyError
1818

1919
class NoScriptError(ReplyError):
@@ -36,5 +36,4 @@ async def eval_sha(
3636
async def eval_sha(
3737
client: aioredis.Redis, digest: str, args: Tuple[Any]
3838
): # pragma: no cover
39-
# return await client.evalsha(digest, 0, *args)
4039
return await client.execute_command("EVALSHA", digest, 0, *args)

yatq/worker/runner.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
import traceback
55
from typing import Dict, List, Optional, Set, Type, cast
66

7-
try:
7+
from yatq.py_version import AIOREDIS_USE
8+
9+
if AIOREDIS_USE:
810
import aioredis
9-
except ImportError:
11+
else: # pragma: no cover
1012
from redis import asyncio as aioredis # type: ignore
1113

14+
1215
from yatq.defaults import DEFAULT_MAX_JOBS, DEFAULT_QUEUE_NAMESPACE
1316
from yatq.dto import TaskWrapper
1417
from yatq.enums import TaskState

yatq/worker/worker_settings.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
from typing import Awaitable, Callable, Dict, Optional, Tuple, Type
33
from abc import ABC, abstractmethod
44

5-
try:
5+
from yatq.py_version import AIOREDIS_USE
6+
7+
if AIOREDIS_USE:
68
import aioredis
7-
except ImportError:
9+
else: # pragma: no cover
810
from redis import asyncio as aioredis # type: ignore
911

1012
from yatq.worker.factory.base import BaseJobFactory

0 commit comments

Comments
 (0)