Skip to content

fix(idempotency): CachePersistenceLayer no longer emits the Redis deprecation warning - #8608

Closed
SirHumza wants to merge 1 commit into
aws-powertools:developfrom
SirHumza:fix/8574-cache-persistence-deprecation-warning
Closed

SirHumza wants to merge 1 commit into
aws-powertools:developfrom
SirHumza:fix/8574-cache-persistence-deprecation-warning

Conversation

@SirHumza

Copy link
Copy Markdown

Summary

Fixes #8574.

CachePersistenceLayer, CacheConnection and CacheClientProtocol were TypeAliases over the deprecated Redis* classes. Because they resolve to the same object, instantiating CachePersistenceLayer(client=...) raised the DeprecationWarning intended for RedisCachePersistenceLayer.

This moves the implementation into cache.py under the Cache* names and keeps redis.py as thin @deprecated subclasses, so only the old Redis* names warn.

Changes

  • cache.py: the implementation now lives here under CacheClientProtocol, CacheConnection and CachePersistenceLayer (no deprecation).
  • redis.py: RedisClientProtocol, RedisConnection and RedisCachePersistenceLayer are now @deprecated subclasses of the corresponding Cache* classes, keeping the old messages.
  • tests: updated the mock.patch targets to the new module location and added a regression test asserting CachePersistenceLayer does not warn while RedisCachePersistenceLayer does.

Testing

$ python -m pytest tests/functional/idempotency/_redis/test_redis_layer.py -q
24 passed

$ python -m pytest tests/functional/idempotency -q
192 passed (2 unrelated collection errors: optional `fastjsonschema` not installed locally)

$ ruff check ... && ruff format --check ...
clean

Behavior check:

CachePersistenceLayer(client=...)          # no warning (before: warned)
RedisCachePersistenceLayer(client=...)    # DeprecationWarning (unchanged)

…recation warning

The new Cache* names were TypeAliases over the deprecated Redis* classes,
so instantiating CachePersistenceLayer raised the deprecation warning meant
for RedisCachePersistenceLayer.

Move the implementation into cache.py under the Cache* names and keep
redis.py as thin @deprecated subclasses, so only the old Redis* names warn.

Fixes #8574
@SirHumza
SirHumza requested a review from a team as a code owner October 18, 2026 12:33
@boring-cyborg

boring-cyborg Bot commented Oct 18, 2026

Copy link
Copy Markdown

Thanks a lot for your first contribution! Please check out our contributing guidelines and don't hesitate to ask whatever you need.
In the meantime, check out the #python channel on our Powertools for AWS Lambda Discord: Invite link

@boring-cyborg boring-cyborg Bot added the tests label Oct 18, 2026
@powertools-for-aws-oss-automation

Copy link
Copy Markdown

No acknowledgement section found. Please make sure you used the template to open a PR and didn't remove the acknowledgment section. Check the template at .github/PULL_REQUEST_TEMPLATE.md#acknowledgment

@powertools-for-aws-oss-automation powertools-for-aws-oss-automation Bot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Oct 18, 2026
@sonarqubecloud

Copy link
Copy Markdown

@SirHumza SirHumza closed this by deleting the head repository Oct 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: CachePersistenceLayer raises the deprecation warning that tells you to use CachePersistenceLayer

1 participant