-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yatq adapted for python 3.11
- Loading branch information
Showing
11 changed files
with
131 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import sys | ||
|
||
AIOREDIS_USE = sys.version_info[0:2] < (3, 11) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,39 @@ | ||
# type: ignore | ||
from typing import Any, Tuple | ||
from yatq.py_version import AIOREDIS_USE | ||
|
||
import aioredis | ||
if AIOREDIS_USE: | ||
import aioredis | ||
|
||
if aioredis.__version__ >= "2.0": # pragma: no cover | ||
from aioredis.exceptions import NoScriptError | ||
if aioredis.__version__ >= "2.0": | ||
from aioredis.exceptions import NoScriptError | ||
|
||
async def eval_sha( | ||
client: aioredis.Redis, digest: str, args: Tuple[Any] | ||
): # pragma: no cover | ||
return await client.evalsha(digest, 0, *args) | ||
async def eval_sha( | ||
client: aioredis.Redis, digest: str, args: Tuple[Any] | ||
): # pragma: no cover | ||
return await client.evalsha(digest, 0, *args) | ||
|
||
else: # pragma: no cover | ||
from aioredis.errors import ReplyError | ||
else: # pragma: no cover | ||
from aioredis.errors import ReplyError | ||
|
||
class NoScriptError(ReplyError): | ||
... | ||
class NoScriptError(ReplyError): | ||
... | ||
|
||
async def eval_sha( | ||
client: aioredis.Redis, digest: str, args: Tuple[Any] | ||
): # pragma: no cover | ||
try: | ||
return await client.evalsha(digest, keys=[], args=list(args)) | ||
except ReplyError as error: | ||
if error.args[0].startswith("NOSCRIPT"): | ||
raise NoScriptError(error.args[0]) | ||
raise | ||
|
||
else: # pragma: no cover | ||
from redis import asyncio as aioredis | ||
from redis.exceptions import NoScriptError | ||
|
||
async def eval_sha( | ||
client: aioredis.Redis, digest: str, args: Tuple[Any] | ||
): # pragma: no cover | ||
try: | ||
return await client.evalsha(digest, keys=[], args=list(args)) | ||
except ReplyError as error: | ||
if error.args[0].startswith("NOSCRIPT"): | ||
raise NoScriptError(error.args[0]) | ||
raise | ||
return await client.execute_command("EVALSHA", digest, 0, *args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters