Description
To get an instance of the redis client (redis.Redis), you can either call the constructor (docs) directly, or use the from_url
method.
In both cases you can specify options using kwargs, but a few of the kwargs are missing from the stub for from_url
. This results in mypy (v1.10.0) giving an error when you use one of those kwargs - for example ssl_ca_data
like so:
import redis
redis.Redis.from_url(
url="redis://abc",
health_check_interval=3,
ssl_ca_data="aaa",
)
s.py:5: error: No overload variant of "from_url" of "Redis" matches argument types "str", "int", "str" [call-overload]
(Using any of the kwargs defined in the stub for from_url
is ok)
At runtime, specifying ssl_ca_data to from_url
works fine, so its a false positive in mypy caused by the inaccurate stub as far as I can tell. Also from examining the insides of from_url
, ssl_ca_data does seem to be a valid kwarg to give it.
From the discussion at #10592 I'm aware that the typing for redis is incomplete and a bit up in the air in general, but this seems like a relatively easy thing to fix.
environment information
python version: 3.11.0
redis version: 4.4.0
types-redis version: 4.5.4.1
edited
corrected url
arg in code excerpt to reflect ssl schema (ie, start with 'redis://').
(This results in the connection_pool.connection_class
in the Redis
object being set as SSLConnection
- a class which has ssl_ca_data
defined as constructor kwarg - so in this case passing ssl_ca_data
to Redis.from_url
is meaningful.)