Repository navigation
fix(idempotency): stop CachePersistenceLayer from emitting the Redis deprecation warning - #8625
Conversation
…deprecation warning CachePersistenceLayer, CacheConnection and CacheClientProtocol were TypeAliases of the deprecated Redis* classes, so they were the same object and @deprecated fired for both. The implementation now lives under the Cache* names and the Redis* names are thin @deprecated subclasses, so only the old names warn. Also fixes the RedisClientProtocol warning text, which named RedisPersistenceLayer/CacheProtocol. Fixes aws-powertools#8574
|
leandrodamascena
left a comment
There was a problem hiding this comment.
Thanks @MrNK2107! I ran the suite with -W always: the Cache* names are silent, the Redis* names still warn with the corrected text, and the old class still works end to end with custom attribute names. Keeping the implementation in redis.py was the right call for the mock targets, and I test-merged this with #8606 on the same file, no conflicts. The isinstance note is fair and the only thing anyone could notice.
Approving now. This goes out in 3.38.0, so it will sit here a bit before I merge. No need to rebase or touch anything, I'll take care of it and you'll get the credit in the release notes. Thank you!
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #8625 +/- ##
========================================
Coverage 96.93% 96.93%
========================================
Files 318 318
Lines 16031 16031
Branches 1423 1426 +3
========================================
Hits 15540 15540
Misses 349 349
Partials 142 142 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|



Issue number: closes #8574
Summary
Changes
CachePersistenceLayer,CacheConnectionandCacheClientProtocolwereTypeAliases of the deprecatedRedis*classes, so they were the same object and@deprecatedfired for both.Cache*names, without the decorator.RedisCachePersistenceLayer,RedisConnectionandRedisClientProtocolare thin@deprecatedsubclasses of them. Only the old names warn, and they still work anywhere aCache*object is expected.CachePersistenceLayer.__init__builds aCacheConnectioninstead of aRedisConnection, so the new name no longer triggers the warning internally.RedisClientProtocolwarning text, which namedRedisPersistenceLayer/CacheProtocol.I kept the implementation in
redis.pyrather than moving it intocache.pyas the issue suggests. That keeps the diff small, keeps existingmock.patch("...persistence.redis.redis")targets working, and avoids conflicting with #8606, which edits the same methods. Happy to do the full move if you prefer.One behaviour note:
isinstance(CachePersistenceLayer(...), RedisCachePersistenceLayer)is nowFalse, because the old name is the subclass. The reverse,isinstance(RedisCachePersistenceLayer(...), CachePersistenceLayer), isTrue.Tests: new functional tests check that the
Cache*names emit noDeprecationWarning, and that theRedis*names still warn with the right message and are instances of theCache*classes. All idempotency tests pass.User experience
Before:
After:
CachePersistenceLayer,CacheConnectionandCacheClientProtocolno longer warn.RedisCachePersistenceLayer(...)still warns as before.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.