Skip to content

Commit 5c4177f

Browse files
fix: avoid instantiating a connection on _repr__
1 parent 91be4a0 commit 5c4177f

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

redis/connection.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1422,10 +1422,16 @@ def __init__(
14221422
self._lock = threading.Lock()
14231423
self.reset()
14241424

1425-
def __repr__(self) -> (str, str):
1425+
def __repr__(self) -> str:
1426+
arg = ""
1427+
if "host" in self.connection_kwargs:
1428+
arg = f"{self.connection_kwargs['host']}:{self.connection_kwargs['port']}"
1429+
elif "path" in self.connection_kwargs:
1430+
arg = self.connection_kwargs["path"]
1431+
14261432
return (
14271433
f"<{type(self).__module__}.{type(self).__name__}"
1428-
f"({repr(self.connection_class(**self.connection_kwargs))})>"
1434+
f"({self.connection_class.__name__}<{arg}>)>"
14291435
)
14301436

14311437
def get_protocol(self):

0 commit comments

Comments
 (0)