Browse Source

fix: lint error

pull/1488/head
phi 10 months ago
parent
commit
a8470ced6e
  1. 11
      src/socketio/async_redis_manager.py
  2. 9
      src/socketio/redis_manager.py

11
src/socketio/async_redis_manager.py

@ -20,8 +20,6 @@ except ImportError: # pragma: no cover
valkey = None valkey = None
ValkeyError = None ValkeyError = None
from .async_pubsub_manager import AsyncPubSubManager from .async_pubsub_manager import AsyncPubSubManager
from .redis_manager import parse_redis_sentinel_url from .redis_manager import parse_redis_sentinel_url
@ -59,7 +57,8 @@ class AsyncRedisManager(AsyncPubSubManager): # pragma: no cover
write_only=False, logger=None, redis_options=None): write_only=False, logger=None, redis_options=None):
if aioredis is None and valkey is None: if aioredis is None and valkey is None:
raise RuntimeError('Redis package is not installed ' raise RuntimeError('Redis package is not installed '
'(Run "pip install redis" or "pip install valkey" ' '(Run "pip install redis" or '
'"pip install valkey" '
'in your virtualenv).') 'in your virtualenv).')
if aioredis and not hasattr(aioredis.Redis, 'from_url'): if aioredis and not hasattr(aioredis.Redis, 'from_url'):
raise RuntimeError('Version 2 of aioredis package is required.') raise RuntimeError('Version 2 of aioredis package is required.')
@ -74,12 +73,14 @@ class AsyncRedisManager(AsyncPubSubManager): # pragma: no cover
if schema == 'redis': if schema == 'redis':
if aioredis is None or RedisError is None: if aioredis is None or RedisError is None:
raise RuntimeError('Redis package is not installed ' raise RuntimeError('Redis package is not installed '
'(Run "pip install redis" in your virtualenv).') '(Run "pip install redis" '
'in your virtualenv).')
return aioredis, RedisError return aioredis, RedisError
if schema == 'valkey': if schema == 'valkey':
if valkey is None or ValkeyError is None: if valkey is None or ValkeyError is None:
raise RuntimeError('Valkey package is not installed ' raise RuntimeError('Valkey package is not installed '
'(Run "pip install valkey" in your virtualenv).') '(Run "pip install valkey" '
'in your virtualenv).')
return valkey, ValkeyError return valkey, ValkeyError
error_msg = f'Unsupported Redis URL schema: {schema}' error_msg = f'Unsupported Redis URL schema: {schema}'
raise ValueError(error_msg) raise ValueError(error_msg)

9
src/socketio/redis_manager.py

@ -82,7 +82,8 @@ class RedisManager(PubSubManager): # pragma: no cover
write_only=False, logger=None, redis_options=None): write_only=False, logger=None, redis_options=None):
if redis is None and valkey is None: if redis is None and valkey is None:
raise RuntimeError('Redis package is not installed ' raise RuntimeError('Redis package is not installed '
'(Run "pip install redis" or "pip install valkey" ' '(Run "pip install redis" '
'or "pip install valkey" '
'in your virtualenv).') 'in your virtualenv).')
super().__init__(channel=channel, write_only=write_only, logger=logger) super().__init__(channel=channel, write_only=write_only, logger=logger)
self.redis_url = url self.redis_url = url
@ -110,12 +111,14 @@ class RedisManager(PubSubManager): # pragma: no cover
if schema == 'redis': if schema == 'redis':
if redis is None or RedisError is None: if redis is None or RedisError is None:
raise RuntimeError('Redis package is not installed ' raise RuntimeError('Redis package is not installed '
'(Run "pip install redis" in your virtualenv).') '(Run "pip install redis" '
'in your virtualenv).')
return redis, RedisError return redis, RedisError
if schema == 'valkey': if schema == 'valkey':
if valkey is None or ValkeyError is None: if valkey is None or ValkeyError is None:
raise RuntimeError('Valkey package is not installed ' raise RuntimeError('Valkey package is not installed '
'(Run "pip install valkey" in your virtualenv).') '(Run "pip install valkey" '
'in your virtualenv).')
return valkey, ValkeyError return valkey, ValkeyError
error_msg = f'Unsupported Redis URL schema: {schema}' error_msg = f'Unsupported Redis URL schema: {schema}'
raise ValueError(error_msg) raise ValueError(error_msg)

Loading…
Cancel
Save