Skip to content

Commit 56314fc

Browse files
Triple quote docstrings in client.py PEP 257
1 parent 41cef47 commit 56314fc

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

redis/client.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ def parse_debug_object(response):
9494

9595

9696
def parse_object(response, infotype):
97-
"Parse the results of an OBJECT command"
97+
"""Parse the results of an OBJECT command"""
9898
if infotype in ("idletime", "refcount"):
9999
return int_or_none(response)
100100
return response
101101

102102

103103
def parse_info(response):
104-
"Parse the result of Redis's INFO command into a Python dict"
104+
"""Parse the result of Redis's INFO command into a Python dict"""
105105
info = {}
106106
response = str_if_bytes(response)
107107

@@ -145,7 +145,7 @@ def get_value(value):
145145

146146

147147
def parse_memory_stats(response, **kwargs):
148-
"Parse the results of MEMORY STATS"
148+
"""Parse the results of MEMORY STATS"""
149149
stats = pairs_to_dict(response, decode_keys=True, decode_string_values=True)
150150
for key, value in stats.items():
151151
if key.startswith("db."):
@@ -219,7 +219,7 @@ def parse_sentinel_get_master(response):
219219

220220

221221
def pairs_to_dict(response, decode_keys=False, decode_string_values=False):
222-
"Create a dict given a list of key/value pairs"
222+
"""Create a dict given a list of key/value pairs"""
223223
if response is None:
224224
return {}
225225
if decode_keys or decode_string_values:
@@ -973,19 +973,15 @@ def __repr__(self):
973973
return f"{type(self).__name__}<{repr(self.connection_pool)}>"
974974

975975
def get_encoder(self):
976-
"""
977-
Get the connection pool's encoder
978-
"""
976+
"""Get the connection pool's encoder"""
979977
return self.connection_pool.get_encoder()
980978

981979
def get_connection_kwargs(self):
982-
"""
983-
Get the connection's key-word arguments
984-
"""
980+
"""Get the connection's key-word arguments"""
985981
return self.connection_pool.connection_kwargs
986982

987983
def set_response_callback(self, command, callback):
988-
"Set a custom Response Callback"
984+
"""Set a custom Response Callback"""
989985
self.response_callbacks[command] = callback
990986

991987
def load_external_module(
@@ -1165,7 +1161,7 @@ def _disconnect_raise(self, conn, error):
11651161

11661162
# COMMAND EXECUTION AND PROTOCOL PARSING
11671163
def execute_command(self, *args, **options):
1168-
"Execute a command and return a parsed response"
1164+
"""Execute a command and return a parsed response"""
11691165
pool = self.connection_pool
11701166
command_name = args[0]
11711167
conn = self.connection or pool.get_connection(command_name, **options)
@@ -1182,7 +1178,7 @@ def execute_command(self, *args, **options):
11821178
pool.release(conn)
11831179

11841180
def parse_response(self, connection, command_name, **options):
1185-
"Parses a response from the Redis server"
1181+
"""Parses a response from the Redis server"""
11861182
try:
11871183
if NEVER_DECODE in options:
11881184
response = connection.read_response(disable_decoding=True)
@@ -1227,7 +1223,7 @@ def __exit__(self, *args):
12271223
self.connection_pool.release(self.connection)
12281224

12291225
def next_command(self):
1230-
"Parse the response from a monitor command"
1226+
"""Parse the response from a monitor command"""
12311227
response = self.connection.read_response()
12321228
if isinstance(response, bytes):
12331229
response = self.connection.encoder.decode(response, force=True)
@@ -1262,7 +1258,7 @@ def next_command(self):
12621258
}
12631259

12641260
def listen(self):
1265-
"Listen for commands coming to the server."
1261+
"""Listen for commands coming to the server."""
12661262
while True:
12671263
yield self.next_command()
12681264

@@ -1355,11 +1351,11 @@ def on_connect(self, connection):
13551351

13561352
@property
13571353
def subscribed(self):
1358-
"Indicates if there are subscriptions to any channels or patterns"
1354+
"""Indicates if there are subscriptions to any channels or patterns"""
13591355
return self.subscribed_event.is_set()
13601356

13611357
def execute_command(self, *args):
1362-
"Execute a publish/subscribe command"
1358+
"""Execute a publish/subscribe command"""
13631359

13641360
# NOTE: don't parse the response in this function -- it could pull a
13651361
# legitimate message off the stack if the connection is already
@@ -1751,7 +1747,7 @@ def __len__(self):
17511747
return len(self.command_stack)
17521748

17531749
def __bool__(self):
1754-
"Pipeline instances should always evaluate to True"
1750+
"""Pipeline instances should always evaluate to True"""
17551751
return True
17561752

17571753
def reset(self):
@@ -1992,7 +1988,7 @@ def _disconnect_raise_reset(self, conn, error):
19921988
raise
19931989

19941990
def execute(self, raise_on_error=True):
1995-
"Execute all the commands in the current pipeline"
1991+
"""Execute all the commands in the current pipeline"""
19961992
stack = self.command_stack
19971993
if not stack and not self.watching:
19981994
return []
@@ -2019,17 +2015,18 @@ def execute(self, raise_on_error=True):
20192015
self.reset()
20202016

20212017
def discard(self):
2022-
"""Flushes all previously queued commands
2018+
"""
2019+
Flushes all previously queued commands
20232020
See: https://redis.io/commands/DISCARD
20242021
"""
20252022
self.execute_command("DISCARD")
20262023

20272024
def watch(self, *names):
2028-
"Watches the values at keys ``names``"
2025+
"""Watches the values at keys ``names``"""
20292026
if self.explicit_transaction:
20302027
raise RedisError("Cannot issue a WATCH after a MULTI")
20312028
return self.execute_command("WATCH", *names)
20322029

20332030
def unwatch(self):
2034-
"Unwatches all previously specified keys"
2031+
"""Unwatches all previously specified keys"""
20352032
return self.watching and self.execute_command("UNWATCH") or True

0 commit comments

Comments
 (0)