You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks to #998 , we have a more accurate type for django.core.cache.cache -> BaseCache.
However, this is a problem for third-party/custom cache backend that implement other methods.
For example django-redislock/keys/... methods.
How is that should be
I'm not sure how to deal with this, and how to declare that my cache backend is using a different type (RedisCache for ex.)
Any idea how I can address this issue ? This is a blocker for me as my project heavily rely on django-redis.
System information
OS:
python version: 3.8
django version: 3.2.14
mypy version: 0.971
django-stubs version: 1.12.0
django-stubs-ext version: 0.5.0
The text was updated successfully, but these errors were encountered:
fromdjango.core.cacheimportcachesfromdjagno_redis.cacheimportRedisCachecache=caches["default"] # or whatever the name of your cache isassertisinstance(cache, RedisCache)
# from here on, Mypy knows it's a RedisCache
You can always create myapp.cache and import the cache object, that uses the above type narrowing, and import from there throughout your code base.
django-redis is kinda outdated since the Redis backend was introduced to Django core. There's perhaps space to add some extra functions to Django core's redis backend, if you propose it. Otherwise you could consider a package that extends the built-in backend.
Bug report
What's wrong
Thanks to #998 , we have a more accurate type for
django.core.cache.cache
->BaseCache
.However, this is a problem for third-party/custom cache backend that implement other methods.
For example django-redis
lock
/keys
/... methods.How is that should be
I'm not sure how to deal with this, and how to declare that my cache backend is using a different type (
RedisCache
for ex.)Any idea how I can address this issue ? This is a blocker for me as my project heavily rely on
django-redis
.System information
python
version: 3.8django
version: 3.2.14mypy
version: 0.971django-stubs
version: 1.12.0django-stubs-ext
version: 0.5.0The text was updated successfully, but these errors were encountered: