Skip to content

Commit

Permalink
Merge pull request #2015 from Badiboy/master
Browse files Browse the repository at this point in the history
Fix aioredis version check for regular redis
  • Loading branch information
Badiboy authored Jul 14, 2023
2 parents 8f41df0 + b18bcd4 commit 0f52ca6
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions telebot/asyncio_storage/redis_storage.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from telebot.asyncio_storage.base_storage import StateStorageBase, StateContext
import json


redis_installed = True
is_actual_aioredis = False
try:
import aioredis
is_actual_aioredis = True
except ImportError:
try:
from redis import asyncio as aioredis
Expand All @@ -23,10 +24,10 @@ def __init__(self, host='localhost', port=6379, db=0, password=None, prefix='tel
if not redis_installed:
raise ImportError('AioRedis is not installed. Install it via "pip install aioredis"')


aioredis_version = tuple(map(int, aioredis.__version__.split(".")[0]))
if aioredis_version < (2,):
raise ImportError('Invalid aioredis version. Aioredis version should be >= 2.0.0')
if is_actual_aioredis:
aioredis_version = tuple(map(int, aioredis.__version__.split(".")[0]))
if aioredis_version < (2,):
raise ImportError('Invalid aioredis version. Aioredis version should be >= 2.0.0')
self.redis = aioredis.Redis(host=host, port=port, db=db, password=password)

self.prefix = prefix
Expand Down

0 comments on commit 0f52ca6

Please sign in to comment.