fix: avoid instantiating a connection on repr_ by robertosantamaria-scopely · Pull Request #3653 · redis/redis-py (original) (raw)
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Pull Request check-list
Please make sure to review and check all of these items:
- Do tests and lints pass with this change?
- Do the CI tests pass with this change (enable it first in your forked repo and wait for the github action build to finish)?
- Is the new or changed code fully tested?
- Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?
- Is there an example added to the examples folder (if applicable)?
NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
Description of change
Changing the __repr__ methods in connection pool classes to avoid instantiating a connection object just to have its string representation.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refines the connection pool’s string representation by avoiding the instantiation of a connection within repr methods. Key changes include:
- Updating repr in both synchronous and asynchronous connection implementations to prevent side effects.
- Adjusting tests to match the updated repr output format.
- Modifying URL-based connection tests to include an explicit database parameter.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/test_connection_pool.py | Updated expected repr strings for ConnectionPool in TCP and Unix socket scenarios. |
| tests/test_asyncio/test_connection_pool.py | Similar repr string updates for the async ConnectionPool tests. |
| redis/connection.py | Revised repr to assemble connection kwargs without instantiating a new connection. |
| redis/asyncio/connection.py | Similar updates to repr for the async connection implementation. |
ManelCoutinhoSensei pushed a commit to ManelCoutinhoSensei/redis-py that referenced this pull request
fix: avoid instantiating a connection on repr_
include full kwargs
Adding repr fix in async connection pool. Fix failing tests.
Co-authored-by: petyaslavova petya.slavova@redis.com
ManelCoutinhoSensei pushed a commit to ManelCoutinhoSensei/redis-py that referenced this pull request
fix: avoid instantiating a connection on repr_
include full kwargs
Adding repr fix in async connection pool. Fix failing tests.
Co-authored-by: petyaslavova petya.slavova@redis.com
petyaslavova added a commit that referenced this pull request
fix: avoid instantiating a connection on repr_
include full kwargs
Adding repr fix in async connection pool. Fix failing tests.
Co-authored-by: petyaslavova petya.slavova@redis.com