Skip to content

fix: avoid instantiating a connection on _repr__ #3653

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 29, 2025

Conversation

robertosantamaria-scopely
Copy link
Contributor

@robertosantamaria-scopely robertosantamaria-scopely commented May 22, 2025

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.

@petyaslavova petyaslavova added the maintenance Maintenance (CI, Releases, etc) label May 23, 2025
@petyaslavova petyaslavova requested a review from Copilot May 28, 2025 11:21
Copy link
Contributor

@Copilot Copilot AI left a comment

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.

@petyaslavova petyaslavova requested a review from vladvildanov May 28, 2025 14:15
@petyaslavova petyaslavova marked this pull request as ready for review May 28, 2025 14:17
@petyaslavova petyaslavova merged commit c1c602d into redis:master May 29, 2025
98 of 100 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Maintenance (CI, Releases, etc)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants