From 43d79d3a2428122bf0284ce7f23fb3773a048a9f Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Thu, 5 Sep 2024 14:37:07 -0700 Subject: [PATCH] [REF-3570] Remove deprecated REDIS_URL syntax (#3892) --- reflex/utils/prerequisites.py | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/reflex/utils/prerequisites.py b/reflex/utils/prerequisites.py index 902c5111c..e061207f4 100644 --- a/reflex/utils/prerequisites.py +++ b/reflex/utils/prerequisites.py @@ -325,24 +325,19 @@ def parse_redis_url() -> str | dict | None: """Parse the REDIS_URL in config if applicable. Returns: - If redis-py syntax, return the URL as it is. Otherwise, return the host/port/db as a dict. + If url is non-empty, return the URL as it is. + + Raises: + ValueError: If the REDIS_URL is not a supported scheme. """ config = get_config() if not config.redis_url: return None - if config.redis_url.startswith(("redis://", "rediss://", "unix://")): - return config.redis_url - console.deprecate( - feature_name="host[:port] style redis urls", - reason="redis-py url syntax is now being used", - deprecation_version="0.3.6", - removal_version="0.6.0", - ) - redis_url, has_port, redis_port = config.redis_url.partition(":") - if not has_port: - redis_port = 6379 - console.info(f"Using redis at {config.redis_url}") - return dict(host=redis_url, port=int(redis_port), db=0) + if not config.redis_url.startswith(("redis://", "rediss://", "unix://")): + raise ValueError( + "REDIS_URL must start with 'redis://', 'rediss://', or 'unix://'." + ) + return config.redis_url async def get_redis_status() -> bool | None: